feat(methods): add blocks.validate method - #1622
Draft
zimeg wants to merge 5 commits into
Draft
Conversation
Add the blocks.validate Web API method to the Slack API client. Callers can validate Block Kit payloads via methods().blocksValidate(req) (and the async equivalent), passing blocks, message, or view as JSON-encoded strings. No scopes are required. Adds the endpoint constant, sync and async interface methods and impls, the request form builder, the request/response model classes (with an errors[] list of code/message/pointer/relatedComponent), the Tier3 rate limit, a local test, and a response sample for type generation. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1622 +/- ##
============================================
- Coverage 73.30% 73.26% -0.05%
- Complexity 4518 4528 +10
============================================
Files 478 479 +1
Lines 14300 14327 +27
Branches 1490 1491 +1
============================================
+ Hits 10483 10497 +14
- Misses 2925 2940 +15
+ Partials 892 890 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
blocks.validate has special rate-limiting conditions rather than a standard tier (see https://docs.slack.dev/reference/methods/blocks.validate), so model it as SpecialTier_blocks_validate instead of Tier3. Regenerate the rate-limit metadata so the committed rate_limit_tiers.json matches the generated output, which also sorts blocks.validate into its correct alphabetical position — this is what was tripping the CI tree-drift check. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Add a blocks_Test integration test under test_with_remote_apis that exercises blocks.validate against the real API: a well-formed payload validates with no errors, and a malformed payload surfaces the live validation feedback (recording the actual contract — ok=false with an error, or ok=true with a populated errors[] carrying code/message/pointer). Refresh the method-coverage scrape marker in MethodsTest to reflect the current 310-endpoint list. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
The method was consistently placed after the bookmarks family, but "blocks" sorts before "bookmarks". Move every insertion site into alphabetical order: request/response imports, the sync/async interface declarations and their implementations, the RequestFormBuilder toForm mapping, the rate-limit tier registration, and the method-coverage string in MethodsTest. Pure reordering — no behavior change. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
blocks.validate requires no token or scopes (https://docs.slack.dev/reference/methods/blocks.validate), so it should not send an Authorization header. Model it like api.test: drop the token field from BlocksValidateRequest (overriding getToken() to return null) and call it through the tokenless postFormAndParseResponse path. The local BlocksTest now asserts the request round-trips (the shared mock answers a tokenless call with not_authed); end-to-end ok/errors[] behavior is covered by the remote blocks_Test. 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.
This pull request adds the
blocks.validateWeb API method to the Slack API client for Java.slack.methods().blocksValidate(req)and the async equivalentslack.methodsAsync().blocksValidate(req).blocks,message, andvieware accepted as JSON-encodedStringarguments (all optional; the API expects exactly one). No token or scopes required — the method is unauthenticated, so the request carries no token (modeled likeapi.test).blocks.validatehas a special rate-limit tier (per the method reference), modeled asSpecialTier_blocks_validate.BLOCKS_VALIDATEendpoint constant, sync + async interface methods and implementations, theRequestFormBuildermapping,BlocksValidateRequest/BlocksValidateResponsemodel classes (the response includes anerrors[]list ofcode/message/pointer/relatedComponent), the special rate-limit tier + metadata entry, and local + remote tests.Category (place an
xin each of the[ ])Testing
./mvnw test -pl slack-api-client -Dtest=test_locally.api.methods.BlocksTestand confirm the sync and async cases pass against the mock Slack API server.Verification (end-to-end, from source)
Because
blocks.validateisn't in a published release yet, verify it end-to-end by building this branch from source and exercising it from the companion example (slack-samples/bolt-java-examples#53):mvn install -Dmaven.test.skip=true— modules install to$HOME/.m2/repositoryas1.49.1-SNAPSHOT.bolt-java-examples/methodsslack-api-clientdependency at that snapshot, then runmvn compile exec:java -Dexec.mainClass=blocks.BlocksValidate.okwith no errors, and a malformed payload returns whatever the live API reports (eitherok=falsewith an error, orok=truewith a populatederrors[]carryingcode/message/pointer/relatedComponent).Remote (integration) tests
test_with_remote_apis/methods/blocks_Testexercisesblocks.validateagainst the real Slack API — a well-formed payload validates cleanly, and a malformed payload surfaces the live validation feedback (recording the actualerrors[]contract).Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you agree to those rules.
🤖 Generated with Claude Code