feat(web-api): add blocks.validate method - #1946
Merged
Merged
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
❌ Your patch check has failed because the patch coverage (41.66%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1946 +/- ##
==========================================
- Coverage 84.17% 84.06% -0.12%
==========================================
Files 118 118
Lines 13470 13506 +36
==========================================
+ Hits 11339 11354 +15
- Misses 2131 2152 +21 ☔ 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 was referenced Aug 26, 2026
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
blocks.validate reads blocks/message/view as JSON-encoded form fields, not a
JSON request body — a JSON body returns invalid_arguments ("must provide
exactly one of blocks, view, or message"). Serialize each provided payload
with json.dumps (converting Block/View objects to dicts first) and send via
params, following conversations.requestSharedInvite.approve. Verified against
the live API: blocks/message/view all validate, and malformed input returns
the errors[] contract.
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>
zimeg
marked this pull request as ready for review
August 26, 2026 17:41
Member
Author
|
@WilliamBergamin Onward with a merge we sail! 🚢 💨 |
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:Validate a Block Kit payload against the Block Kit schema by passing exactly one of:
blocks— a list ofBlockobjects (or dicts, or a JSON string)message— a message payload dict (or JSON string)view— aView(or dict, or JSON string)blocks.validateis unauthenticated (no token or scopes), so the method can be called without a configured token — matching the in-flight Node (slackapi/node-slack-sdk#2659) and Java (slackapi/java-slack-sdk#1622) additions.Implementation notes:
chat_postMessage/views_open:Blockobjects are serialized via_parse_web_class_objects, aViewviaview.to_dict(), and the payload is sent as JSON.slack_sdk/web/client.pyis the source of truth;async_client.pyandlegacy_client.pyare regenerated viapython scripts/codegen.py.blocks.validateadded to the web client coverage endpoint list (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).python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shCategory
tests/integration_tests(Automated tests for this library)Requirements
./scripts/run_validation.shafter making the changes. (See reviewer note — could not run locally; CI covers it.)🤖 Generated with Claude Code