Skip to content

fix(models): skip unknown view state values instead of crashing - #2043

Merged
mwbrooks merged 3 commits into
mainfrom
fix/view-state-skip-unknown-values
Nov 16, 2026
Merged

mwbrooks merged 3 commits into
mainfrom
fix/view-state-skip-unknown-values

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

Summary

This pull request makes ViewState actually skip the unknown state values it already warns about.

  • Each block's actions were copied before parsing, so a value that was warned about and "skipped" stayed in place, and to_dict() then raised AttributeError calling .to_dict() on it. Now the parsed actions start from {}, as Option.parse_all does. The now-unused type: ignore goes with it.
  • The non-dict block branch warned with the inner loop's leftover v. As the first block, that raised UnboundLocalError; after another block, it named the wrong value. Now it warns with actions.
  • Slack only sends objects here, so this only affects hand-built ViewStates. Those values could never be serialized, and the warning already promised a skip. The legacy slack package re-exports slack_sdk.models.views, so it gets the fix too.

Testing

The new tests fail on main and pass on this branch:

  • An int action value is skipped with a warning naming builtins.int, and to_dict() keeps the valid sibling.
  • A non-dict block after a valid one warns naming builtins.str, not the previous action's value; a non-dict first block no longer raises.

Category

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs (Documents)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements

🤖 Generated with Claude Code

ViewState copied each block's actions before parsing them, so values
it warned about and meant to skip stayed in place and crashed
to_dict(). Its non-dict block branch warned with a leftover loop
variable, raising UnboundLocalError or naming the wrong value.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.47%. Comparing base (f4b0575) to head (d0e310f).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2043      +/-   ##
==========================================
+ Coverage   84.40%   84.47%   +0.07%     
==========================================
  Files         118      118              
  Lines       14035    14035              
==========================================
+ Hits        11846    11856      +10     
+ Misses       2189     2179      -10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@WilliamBergamin
WilliamBergamin marked this pull request as ready for review November 16, 2026 17:02
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner November 16, 2026 17:02

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🐍 @WilliamBergamin LGTM! Thanks for making the skip actually skip.

@mwbrooks mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

✅ Appreciate this one @WilliamBergamin, the tests that fail on main make both crashes easy to see.

@mwbrooks
mwbrooks merged commit 4639eee into main Nov 16, 2026
19 checks passed
@mwbrooks
mwbrooks deleted the fix/view-state-skip-unknown-values branch November 16, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants