Add "client.showErrorLinks` config option (#11238)"#13472
Add "client.showErrorLinks` config option (#11238)"#13472sfc-gh-lwilby merged 11 commits intostreamlit:developfrom
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Thanks for contributing to Streamlit! 🎈 Please make sure you have read our Contributing Guide. You can find additional information about Streamlit development in the wiki. The review process:
We're receiving many contributions and have limited review bandwidth — please expect some delay. We appreciate your patience! 🙏 |
|
@cursor review |
There was a problem hiding this comment.
Pull request overview
This PR adds a new client.showExceptionLinks configuration option that allows users to disable external help links (Copy, Ask Google, Ask ChatGPT) displayed in exception messages when running on localhost. This addresses privacy and security concerns for organizations that prohibit ChatGPT usage due to data leak risks, GDPR compliance, or intellectual property concerns.
Key Changes:
- Added
client.showExceptionLinksconfig option (default:true) in Python backend - Extended protobuf
Configmessage withshow_exception_linksfield - Updated frontend to conditionally render exception links based on the config value
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| proto/streamlit/proto/NewSession.proto | Added show_exception_links field to Config message (field number 9) |
| lib/streamlit/config.py | Defined new client.showExceptionLinks config option with description and default value |
| lib/streamlit/runtime/app_session.py | Populated the protobuf config message with the new option value |
| lib/tests/streamlit/config_test.py | Added config option key to test assertions |
| frontend/lib/src/components/core/LibConfigContext.tsx | Added showExceptionLinks property to context interface with documentation |
| frontend/app/src/components/StreamlitContextProvider.tsx | Added property to provider props and memoization dependencies |
| frontend/app/src/App.tsx | Added state variable for the config, populated from backend config, and passed to context provider |
| frontend/lib/src/components/elements/ExceptionElement/ExceptionElement.tsx | Consumed context value and added conditional rendering of exception links |
| frontend/lib/src/test_util.tsx | Added default value for test context |
| frontend/lib/src/components/elements/ExceptionElement/ExceptionElement.test.tsx | Added test case verifying links are hidden when config is false |
frontend/lib/src/components/elements/ExceptionElement/ExceptionElement.test.tsx
Show resolved
Hide resolved
|
Addressed the comment |
|
Thank you, looks like it needs security label as well. I can not edit it. |
|
Hey, thanks for the contribution. I'm in principle OK with adding this but:
|
|
Sounds good, I made the both changes. |
SummaryThis PR adds a new The implementation spans:
Code QualityStrengths
Issues
/**
* Whether to show external help links (Google, ChatGPT) in exception displays
* when running on localhost. Defaults to true.
*
* Consumed by:
* @see ExceptionElement
*/The comment says "Defaults to true" but the actual default is
if enum_value is None:
allowed_values = "auto, true, false"
raise ValueError(
f"Config {config_key!r} expects to have one of "
f"the following values: {allowed_values}. "
f"Current value: {config_value}"
)Unlike allowed_values = ", ".join(k.replace("SHOW_ERROR_LINKS_", "").lower() for k in Config.ShowErrorLinks.keys())Test CoverageFrontend Tests ✅The frontend unit tests (
Python Tests ✅
Missing Tests (Acceptable)
Backwards CompatibilityProtobuf Changes ✅The protobuf changes are backwards compatible:
Config Default ✅
Security & RiskSecurity Improvements ✅This PR improves security by:
Risk Assessment ✅Low risk:
Recommendations
VerdictAPPROVED: This is a well-implemented feature that addresses legitimate privacy/security concerns. The code follows existing patterns, is properly tested, and maintains backwards compatibility. The minor issues identified (PR description naming, JSDoc comment accuracy, hardcoded error message) are non-blocking and can be addressed in a follow-up if desired. This is an automated AI review. Please verify the feedback and use your judgment. |
There was a problem hiding this comment.
Maybe update the title of the test to specify "when no showErrorLinks config is set".
There was a problem hiding this comment.
And update this one to specify "should not render exception links for non-localhost when no showErrorLinks config is set" (it looks like this test also has an error and should be non-localhost not localhost).
| expect(screen.getByText("Ask Google")).toBeInTheDocument() | ||
| expect(screen.getByText("Ask ChatGPT")).toBeInTheDocument() | ||
| }) | ||
| }) |
There was a problem hiding this comment.
I think these tests are fairly cheap to run, so we might as well add the other cases (i.e. config true + localhost, config false + non-localhost). Maybe you could parameterize them to reduce the reading overhead.
|
|
||
| // See config option "client.showErrorLinks". | ||
| enum ShowErrorLinks { | ||
| SHOW_ERROR_LINKS_AUTO = 0; |
There was a problem hiding this comment.
We don't do this for all enums, but the proto best practices specify using this first value as an unspecified value. So, SHOW_ERROR_LINKS_UNSPECIFIED = 0; and then SHOW_ERROR_LINKS_AUTO = 1;.
| return enum_value | ||
|
|
||
|
|
||
| def _get_show_error_links() -> Config.ShowErrorLinks.ValueType: |
There was a problem hiding this comment.
[suggestion: non-blocking] I guess we can keep this code like this, I see this follows the _get_toolbar_mode pattern above. It seems like the intention is to not have to keep a list of valid config options in sync with the proto enum. I am not sure how often we would be adding enum values to make this a big concern though. It would be easier to read if we just had something like this ...
allowed_values = ["auto", "true", "false"]
config_value = config.get_option("client.showErrorLinks")
if config_value not in allowed_values:
... error
map_to_enum = {
"auto" : Config.ShowErrorLinks.SHOW_ERROR_LINKS_AUTO,
...
}
return map_to_enum.get(config_value)
Not blocking, since we are doing this above.
lib/streamlit/runtime/app_session.py
Outdated
| if enum_value is None: | ||
| allowed_values = ", ".join( | ||
| k.replace("SHOW_ERROR_LINKS_", "").lower() | ||
| for k in Config.ShowErrorLinks.keys() # noqa: SIM118 |
There was a problem hiding this comment.
If you don't do the above changes, we should change this to an array comprehension so we don't need this noqa.
I.e.
allowed_values = [k.replace("SHOW_ERROR_LINKS_").lower() for k in Config.ShowErrorLinks.keys()]
| return enum_value | ||
|
|
||
|
|
||
| def _get_show_error_links() -> Config.ShowErrorLinks.ValueType: |
There was a problem hiding this comment.
I think it would be good to add some tests for this function, I think it won't be covered currently. Cursor is recommending adding the tests into app_session_test.py and you can use with patch_config_options({"client.toolbarMode": config_value}): to test the different options map to the right enum values and also that invalid values throw the right error and no config maps to the default.
|
Thanks for the comments @sfc-gh-lwilby, addressed and resolved the conflict with the last 2 commits. |
|
Thanks @karubian ! I will try to take a look tomorrow. I have re-run your CI. |
|
Thank you, remaining CI issue does not look related to the change. |
|
Could you look into the permission issue in CI? Please LMK if it is related to the change. |
sfc-gh-lwilby
left a comment
There was a problem hiding this comment.
@karubian thanks for addressing all my feedback. Looks ready to merge 🚀
|
Awesome, thanks for getting this merged! @karubian we'd love to send you some swag as a little thank you, feel free to fill out this form: https://docs.google.com/forms/d/e/1FAIpQLSe7cXh3H1DmrgNpVew9qViGIHX7vdEbTv5isA44_z5bgaKTKg/viewform |
|
Thank you for your help and reviews. I filled the form. |
Describe your changes
Adds a new client.showExceptionLinks config option that allows users to disable the Google/ChatGPT help
links shown in exception displays on localhost.
When set to false in .streamlit/config.toml:
toml
[client]
showExceptionLinks = false
The external help links (Copy, Ask Google, Ask ChatGPT) will be hidden from exception messages.
This addresses privacy and security concerns for companies that prohibit ChatGPT due to data leak risks,
GDPR compliance, or IP concerns - as error messages may contain sensitive data like queries, table
names, or PII.
Screenshot or video (only for visual changes)
GitHub Issue Link (if applicable)
Closes #11238
Testing Plan
showExceptionLinks is false
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.