feat(web-api): add blocks.validate method - #1946
Draft
zimeg wants to merge 3 commits into
Draft
Conversation
Add the `blocks.validate` Web API method to the sync, async, and legacy
web clients. Call it as `client.blocks_validate(blocks=...)` to validate a
Block Kit payload (`blocks`, `message`, or `view`, each a JSON-encoded
string) against the Block Kit schema, instead of the untyped
`client.api_call("blocks.validate", ...)` escape hatch. The method is
unauthenticated (no token or scopes required) per the method reference.
The sync `client.py` is the source of truth; `async_client.py` and
`legacy_client.py` are regenerated via `scripts/codegen.py`. Adds
`blocks.validate` to the web client coverage test's endpoint list.
Ref: https://docs.slack.dev/reference/methods/blocks.validate
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1946 +/- ##
=======================================
Coverage 84.17% 84.18%
=======================================
Files 118 118
Lines 13470 13494 +24
=======================================
+ Hits 11339 11360 +21
- Misses 2131 2134 +3 ☔ View full report in Codecov by Harness. |
Bring blocks_validate to parity with chat_postMessage / views_open: accept Block objects (Union[str, Sequence[Union[Dict, Block]]]) and a View/dict for view, serialize them via _parse_web_class_objects and view.to_dict(), and send as json. message accepts a dict or JSON string. client.py is the source of truth; async_client.py and legacy_client.py are regenerated via scripts/codegen.py. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
blocks.validateWeb API method to the sync, async, and legacy web clients:Provide exactly one of
blocks,message, orview, each a JSON-encoded string, to validate a Block Kit payload against the Block Kit schema — instead of the untypedclient.api_call("blocks.validate", ...)escape hatch. The method is unauthenticated (no token or scopes required) per the method reference.This brings Python to parity with the in-flight Node (slackapi/node-slack-sdk#2659) and Java (slackapi/java-slack-sdk#1622)
blocks.validateadditions.Implementation notes:
slack_sdk/web/client.pyis the source of truth;async_client.pyandlegacy_client.pyare regenerated viapython scripts/codegen.py(not hand-edited).blocks.validateadded to the web client coverage endpoint list (count 308 → 309).Testing
blocks.validateis exercised bytests/slack_sdk_async/web/test_web_client_coverage.py(the endpoint-coverage test asserts every listed method is exposed on all three clients). The method's args are all optional, so it is covered by the default no-arg invocation path.python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shCategory
/docs(Documents)/tutorial(PythOnBoardingBot tutorial)tests/integration_tests(Automated tests for this library)Requirements
python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shafter making the changes. (See reviewer note above — could not run locally; CI covers it.)🤖 Generated with Claude Code