Skip to content

[fix] Support boolean values for client.showErrorLinks config option#13806

Merged
sfc-gh-nbellante merged 1 commit intodevelopfrom
nb/fix-showErrorLinks-boolean-config
Feb 3, 2026
Merged

[fix] Support boolean values for client.showErrorLinks config option#13806
sfc-gh-nbellante merged 1 commit intodevelopfrom
nb/fix-showErrorLinks-boolean-config

Conversation

@sfc-gh-nbellante
Copy link
Copy Markdown
Contributor

@sfc-gh-nbellante sfc-gh-nbellante commented Feb 3, 2026

Summary

Fixes the client.showErrorLinks config option to accept boolean values (True/False) in addition to string values ("auto", "true", "false").

Previously, setting the config option with a boolean like client.showErrorLinks = false in config.toml would not work because the code only checked for string values. This change aligns showErrorLinks with the behavior of other config options that accept both boolean and string values.

Test plan

  • Added unit tests for boolean True and False values
  • All existing tests pass
  • Verified manually that client.showErrorLinks = false in config.toml now works correctly

The client.showErrorLinks config option was only accepting string values
("auto", "true", "false"). This change adds support for boolean values
(True, False), matching the behavior of other config options like
client.showSidebarNavigation.

This allows users to set the option programmatically without needing
to convert booleans to strings.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 3, 2026

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13806/streamlit-1.53.1-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13806.streamlit.app (☁️ Deploy here if not accessible)

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sfc-gh-nbellante sfc-gh-nbellante changed the title Fix client.showErrorLinks config to accept boolean values [fix] Support boolean values for client.showErrorLinks config option Feb 3, 2026
@sfc-gh-nbellante sfc-gh-nbellante added security-assessment-completed change:bugfix PR contains bug fix implementation impact:users PR changes affect end users ai-review If applied to PR or issue will run AI review workflow labels Feb 3, 2026
@github-actions github-actions bot removed the ai-review If applied to PR or issue will run AI review workflow label Feb 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 3, 2026

Summary

This PR fixes the client.showErrorLinks config option to accept boolean values (True/False) in addition to string values ("auto", "true", "false"). Previously, setting the config option with a boolean like client.showErrorLinks = false in config.toml would fail because the code only checked for string values. This is a valid bug because TOML distinguishes between false (boolean) and "false" (string).

Files changed:

  • lib/streamlit/runtime/app_session.py - Added boolean handling in _get_show_error_links()
  • lib/tests/streamlit/runtime/app_session_test.py - Added unit tests for boolean values

Code Quality

The implementation is clean and follows existing patterns in the codebase:

  1. Correct use of identity comparison: Using is True and is False (rather than truthiness checks) is the correct approach here because:

    • It explicitly matches only Python boolean values
    • It avoids accidentally matching other truthy/falsy values like strings
    • This pattern is used elsewhere in the codebase (e.g., line 1041 for client.showSidebarNavigation)
  2. Clear code organization: The boolean checks are placed before the string checks with a helpful comment explaining the two sources of config values (programmatic vs. config.toml/CLI).

  3. No unnecessary changes: The PR is focused and makes only the minimum required changes.

Test Coverage

The test coverage is adequate:

  • test_bool_true: Verifies boolean True returns SHOW_ERROR_LINKS_TRUE
  • test_bool_false: Verifies boolean False returns SHOW_ERROR_LINKS_FALSE

The tests follow the existing pattern in the GetShowErrorLinksTest class and include appropriate docstrings. The existing tests already cover:

  • String values: "auto", "true", "false"
  • Invalid string values raise ValueError

Note on anti-regression assertions: The Python test guidelines recommend including negative assertions when practical. While the new tests don't include explicit assertions that other enum values are NOT returned, this is consistent with the existing tests in the same class. The assertion equality check implicitly validates this.

Backwards Compatibility

Fully backwards compatible. This change only adds new functionality without modifying existing behavior:

  • String values ("auto", "true", "false") continue to work exactly as before
  • Invalid values still raise ValueError with the same error message
  • The default value "auto" is unaffected

The boolean handling is checked first, so it takes priority, but since booleans and strings are distinct types in Python, this cannot interfere with existing string-based configurations.

Security & Risk

Low risk. This is a straightforward bug fix with:

  • No security implications (config option affects only UI error display)
  • No external dependencies affected
  • Clear scope limited to one config option
  • Well-tested behavior

Edge cases handled correctly:

  • None would pass through to string validation and raise ValueError (correct)
  • Integers 0/1 would similarly raise ValueError (correct, since 0 is False returns False in Python)

Recommendations

No required changes. The PR is ready for merge.

Optional improvements (not blocking):

  1. Consider updating the config option docstring in lib/streamlit/config.py (line 622-625) to explicitly mention that boolean values are also accepted, though the current description is technically correct since TOML treats unquoted true/false as booleans.

  2. For completeness, you could add a test for None to verify it raises ValueError, but this is an edge case that's already covered by the invalid value test logic.

Verdict

APPROVED: Clean, well-tested bug fix that correctly handles boolean config values from TOML files while maintaining full backwards compatibility with existing string-based configurations.


This is an automated AI review using opus-4.5-thinking. Please verify the feedback and use your judgment.

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Feb 3, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sfc-gh-nbellante sfc-gh-nbellante marked this pull request as ready for review February 3, 2026 19:44
Copilot AI review requested due to automatic review settings February 3, 2026 19:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the client.showErrorLinks configuration handling so that boolean values (True/False) are supported alongside existing string values ("auto", "true", "false"), fixing cases where a boolean in config.toml or programmatic settings previously failed.

Changes:

  • Updated _get_show_error_links to interpret boolean config values and map them to the appropriate Config.ShowErrorLinks enum before performing string validation.
  • Added unit tests to cover client.showErrorLinks when set to True and False, alongside the existing string-based tests and invalid-value check.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/streamlit/runtime/app_session.py Updates _get_show_error_links to handle boolean config values by returning the correct ShowErrorLinks enum for True/False before falling back to the existing string-based validation and mapping.
lib/tests/streamlit/runtime/app_session_test.py Extends GetShowErrorLinksTest with two new tests ensuring client.showErrorLinks set to True or False resolves to the correct enum value, preserving the invalid-value error behavior.

@sfc-gh-nbellante sfc-gh-nbellante merged commit c04c0d9 into develop Feb 3, 2026
88 of 89 checks passed
@sfc-gh-nbellante sfc-gh-nbellante deleted the nb/fix-showErrorLinks-boolean-config branch February 3, 2026 21:11
github-actions bot pushed a commit that referenced this pull request Feb 3, 2026
…13806)

## Summary

Fixes the `client.showErrorLinks` config option to accept boolean values
(`True`/`False`) in addition to string values (`"auto"`, `"true"`,
`"false"`).

Previously, setting the config option with a boolean like
`client.showErrorLinks = false` in config.toml would not work because
the code only checked for string values. This change aligns
`showErrorLinks` with the behavior of other config options that accept
both boolean and string values.

## Test plan

- Added unit tests for boolean `True` and `False` values
- All existing tests pass
- Verified manually that `client.showErrorLinks = false` in config.toml
now works correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants