feat(web-api): add blocks.validate method - #2659
Merged
Merged
Conversation
Add a typed blocks.validate method so callers can validate Block Kit
payloads via client.blocks.validate({ blocks }) instead of the untyped
client.apiCall('blocks.validate', ...) escape hatch. blocks, message, and
view arguments are all optional JSON-encoded strings; no scopes required.
The response type is a minimal placeholder covering the fields common to
all Web API responses; the errors[] array on a failed validation is left
to be generated from a real sample (no blocks.validate.json exists in the
upstream java-slack-sdk logs yet).
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
🦋 Changeset detectedLatest commit: a131e99 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2659 +/- ##
=======================================
Coverage 89.15% 89.15%
=======================================
Files 65 65
Lines 10383 10393 +10
Branches 473 473
=======================================
+ Hits 9257 9266 +9
- Misses 1095 1096 +1
Partials 31 31
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
5 tasks
- Request args accept typed Block Kit values (blocks: (KnownBlock | Block)[],
message: { blocks, attachments }, view: View) instead of JSON strings,
matching chat.postMessage / views.open. The message shape omits text, which
the endpoint rejects as an additional property.
- Response now types the errors[] returned on failed validation: each Error
has pointer/code/message/constraint, where constraint.expected/got are a
string|number|string[] union (polymorphic across enum vs length/count
constraints). Removes the placeholder note that omitted errors[].
Verified: tsc build clean; the blocks.validate tsd type tests pass (the 6
remaining tsd errors are pre-existing in files/rtm test-d, untouched here).
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…e form Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Generated from a blocks.validate sample covering both constraint shapes: expected is string[] | number and got is number | string (enum vs length/count constraints). Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
blocks.validate is unauthenticated (no token or scopes), so its arguments should not offer a token override, matching api.test. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
blocks.validate is unauthenticated, so the type test constructs WebClient() without a token, matching the example. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
zimeg
marked this pull request as ready for review
August 26, 2026 17:41
Regenerate BlocksValidateResponse from the recorded blocks.validate sample via the standard type generator. constraint.expected/got are string[]/string (the shape captured in the fixture) rather than the previously hand-edited union, so the file matches what scripts/generate-web-api-types.sh produces. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
WilliamBergamin
approved these changes
Aug 26, 2026
WilliamBergamin
left a comment
Contributor
There was a problem hiding this comment.
Nice addition, LGTM. 🚀
Member
Author
|
@WilliamBergamin It's a cool method! Thanks for looking this over. |
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.validatemethod to@slack/web-api:Validate a Block Kit payload against the Block Kit schema by passing exactly one of:
blocks— a typed(KnownBlock | Block)[]message— a{ blocks, attachments }payloadview— aViewblocks.validateis unauthenticated (no token or scopes). This brings Node to parity with the in-flight Python (slackapi/python-slack-sdk#1946) and Java (slackapi/java-slack-sdk#1622) additions.Typed request arguments
Arguments accept typed Block Kit values (not JSON strings), matching
chat.postMessage/views.open. Themessageshape intentionally omitstext— the endpoint rejects it as an additional property (verified against the live API).Typed
errors[]responseOn a failed validation the response returns
errors[], each withpointer(a JSON pointer to the offending element),code,message, and aconstraint. The constraint'sexpected/gotare typedstring | number | string[]because their shape is polymorphic across constraint types (a string array forenum, a number formin_length/max_length/max_items, or absent forall_of).Testing
npm run build(tsc) is clean.packages/web-api/test/types/methods/blocks.test-d.tscovers the typedblocks/message/viewargs and asserts the old JSON-string form is now a type error.🤖 Generated with Claude Code