Skip to content

feat(web-api): add blocks.validate method - #1946

Draft
zimeg wants to merge 3 commits into
mainfrom
clack/blocks-validate
Draft

feat(web-api): add blocks.validate method#1946
zimeg wants to merge 3 commits into
mainfrom
clack/blocks-validate

Conversation

@zimeg

@zimeg zimeg commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

Adds the blocks.validate Web API method to the sync, async, and legacy web clients:

client.blocks_validate(blocks='[{"type":"section","text":{"type":"plain_text","text":"Hello world"}}]')

Provide exactly one of blocks, message, or view, each a JSON-encoded string, to validate a Block Kit payload 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.

This brings Python to parity with the in-flight Node (slackapi/node-slack-sdk#2659) and Java (slackapi/java-slack-sdk#1622) blocks.validate additions.

Implementation notes:

  • slack_sdk/web/client.py is the source of truth; async_client.py and legacy_client.py are regenerated via python scripts/codegen.py (not hand-edited).
  • blocks.validate added to the web client coverage endpoint list (count 308 → 309).

Testing

  • blocks.validate is exercised by tests/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.
  • Run: python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh

Reviewer note: I was unable to run run_validation.sh locally in my environment (test dependencies such as aiohttp/pytest were not installed, and formatting via black was unavailable). The generated files were produced by scripts/codegen.py and re-running it is idempotent; source-level checks (AST signatures, py_compile) pass. Please run the validation script before merging.

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

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes. (See reviewer note above — could not run locally; CI covers it.)

🤖 Generated with Claude Code

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

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.18%. Comparing base (ac312d4) to head (0f86aaa).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
slack_sdk/web/async_client.py 87.50% 1 Missing ⚠️
slack_sdk/web/client.py 87.50% 1 Missing ⚠️
slack_sdk/web/legacy_client.py 87.50% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

zimeg and others added 2 commits August 25, 2026 17:05
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant