Skip to content

feat(methods): add blocks.validate method - #1622

Draft
zimeg wants to merge 5 commits into
mainfrom
blocks-validate
Draft

feat(methods): add blocks.validate method#1622
zimeg wants to merge 5 commits into
mainfrom
blocks-validate

Conversation

@zimeg

@zimeg zimeg commented Jul 14, 2026

Copy link
Copy Markdown
Member

This pull request adds the blocks.validate Web API method to the Slack API client for Java.

  • Callers can validate Block Kit payloads via slack.methods().blocksValidate(req) and the async equivalent slack.methodsAsync().blocksValidate(req).
  • blocks, message, and view are accepted as JSON-encoded String arguments (all optional; the API expects exactly one). No token or scopes required — the method is unauthenticated, so the request carries no token (modeled like api.test).
  • Rate limiting: blocks.validate has a special rate-limit tier (per the method reference), modeled as SpecialTier_blocks_validate.
  • Adds: the BLOCKS_VALIDATE endpoint constant, sync + async interface methods and implementations, the RequestFormBuilder mapping, BlocksValidateRequest / BlocksValidateResponse model classes (the response includes an errors[] list of code/message/pointer/relatedComponent), the special rate-limit tier + metadata entry, and local + remote tests.

Category (place an x in each of the [ ])

  • bolt (Bolt for Java)
  • bolt-{sub modules} (Bolt for Java - optional modules)
  • slack-api-client (Slack API Clients)
  • slack-api-model (Slack API Data Models)
  • slack-api-*-kotlin-extension (Kotlin Extensions for Slack API Clients)
  • slack-app-backend (The primitive layer of Bolt for Java)

Testing

  • Run ./mvnw test -pl slack-api-client -Dtest=test_locally.api.methods.BlocksTest and confirm the sync and async cases pass against the mock Slack API server.

Verification (end-to-end, from source)

Because blocks.validate isn'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):

  • Build from source per the Java SDK setup guide: mvn install -Dmaven.test.skip=true — modules install to $HOME/.m2/repository as 1.49.1-SNAPSHOT.
  • Point the bolt-java-examples/methods slack-api-client dependency at that snapshot, then run mvn compile exec:java -Dexec.mainClass=blocks.BlocksValidate.
  • Confirm a well-formed payload returns ok with no errors, and a malformed payload returns whatever the live API reports (either ok=false with an error, or ok=true with a populated errors[] carrying code/message/pointer/relatedComponent).

Remote (integration) tests

test_with_remote_apis/methods/blocks_Test exercises blocks.validate against the real Slack API — a well-formed payload validates cleanly, and a malformed payload surfaces the live validation feedback (recording the actual errors[] 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

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

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.26%. Comparing base (4d86807) to head (2764f52).
⚠️ Report is 12 commits behind head on main.
✅ All tests successful. No failed tests found.

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     
Flag Coverage Δ
jdk-14 73.26% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

zimeg and others added 4 commits August 14, 2026 18:30
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>
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