You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Agents can inspect an API method's input schema, but cannot check a proposed input with the CLI before making a request. Add schema <method> --validate for offline validation using the same catalog, identity filtering, and command visibility as schema inspection.
schema <method> --validate <JSON | @file | ->
resolve visible method
read through invocation FileIO/stdin
validate the published inputSchema
→ stdout: success envelope, exit 0
→ stderr: typed field errors, exit 2
Changes
Validate nested types, required properties, array items, enums, and inclusive numeric bounds. Preserve exact decimal comparisons, including integers beyond float64 precision and large exponents.
Reject duplicate keys, multiple JSON documents, and nesting beyond 64 containers. Report deterministic RFC 6901 JSON Pointers, cap diagnostics at 100 violations with an explicit truncation hint, and avoid echoing submitted field values.
Support inline JSON, @file, and stdin with invocation-scoped FileIO. Resolve the method before consuming input; preserve typed errors and their causes.
Add owner, command, and root-output regressions, fuzz coverage, and English/Chinese documentation. Existing inspection output is preserved.
The input is the emitted inputSchema object (params/data/file, where declared), not a raw request body. Unknown properties remain allowed; defaults and formats are annotations. Validation neither opens upload paths nor establishes authorization, dangerous-operation confirmation, or server-side acceptance. No dependencies or generated catalog files change.
Evidence
Before: the upstream CLI rejected schema ... --validate with exit 2 and unknown flag "--validate".
After: with isolated configuration and no supplied credentials, all three input sources succeed:
Invalid input:{"params":{"page_size":201,"direction":"PRIVATE"}} exits 2, leaves stdout empty, and reports /params/direction and /params/page_size in error.params without exposing the supplied enum value.
20-second fuzz run passed with 6,402,312 executions. Regression tests cover exact numeric boundaries, nested arrays, duplicate keys, stdin/files, FileIO closure and policy failures, identity/visibility restrictions, catalog failures, and real root envelopes.
Test Plan
Focused schema and root-command regressions.
All unit-test packages passed with race detection across the main suite and a separate wrapper-package run (Go 1.23.12, macOS system linker).
The full make unit-test invocation passed every package except extension/command: its generated wrapper binary failed to load with macOS missing LC_UUID. That package passed separately with the system linker also applied to child builds. Applying that flag globally to the full suite instead breaks existing CGO-disabled cross-platform import checks, so the two runs are reported separately. Clearing agent-detection variables isolates existing agent-header tests. The host Go 1.26 race runtime crashed before test execution. Full integration/live-tenant suites were not run; this feature performs no API calls.
Merge Danger
Door: two-way — revert the additive flag and validator; no persisted-state migration.
Blast Radius: schema — new validation behavior and the shared method-resolution helper. Existing inspection, visibility, identity filtering, and typed-error contracts are covered by regressions.
No actionable comments were generated in the recent review.
Walkthrough
The schema package now validates JSON input against supported method schemas. The schema command exposes offline validation through --validate, reports validation results, and preserves catalog rendering when validation is not selected. The README files document the option, input limits, and output behavior.
Changes: Schema Input Validation
Layer / File(s)
Summary
Schema validation and numeric comparison internal/schema/decimal.go, internal/schema/validate.go, internal/schema/validate_test.go
The schema package parses JSON with depth and duplicate-key checks, validates supported types and constraints, and reports capped violations with JSON Pointer paths. Decimal comparisons preserve numeric precision. Tests cover validation rules, limits, diagnostics, and numeric comparisons.
The command dispatches explicit --validate requests to method input validation and retains catalog rendering otherwise. Tests cover input sources, selectors, output, and error handling. The README files document usage and output behavior.
sequenceDiagram
participant User
participant SchemaCommand
participant ValidateRun
participant InputValidator
User->>SchemaCommand: Select --validate for a method
SchemaCommand->>ValidateRun: Dispatch validation request
ValidateRun->>InputValidator: Check input against method schema
InputValidator-->>ValidateRun: Return violations or valid result
ValidateRun-->>User: Return success envelope or validation error
Loading
Merge Risk: Minimal · up to f18c2
This adds an opt-in offline schema --validate mode and leaves existing schema inspection unchanged. No concrete defect was found in the validator, the command wiring or the documentation, and the reported tests cover the main behaviors. The change is low risk to merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "feat(schema): add offline input validation" matches the main change: a new schema <method> --validate flag that validates input offline against the published inputSchema. It is short, spe…
Description check
The description follows the repository template. It has a Summary that states the motivation and scope, a Changes list, a Test Plan with checkboxes, and a Related Issues section stating None. It goes …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat(schema): add offline input validation" matches the main change: a new schema <method> --validate flag that validates input offline against the published inputSchema. It is short, specific, and follows a conventional commit style.
Full details: Description check
Explanation
The description follows the repository template. It has a Summary that states the motivation and scope, a Changes list, a Test Plan with checkboxes, and a Related Issues section stating None. It goes beyond the template with Evidence and Merge Danger sections, which do not conflict with it. The Test Plan does not literally tick the 'Manual local verification' item in the template's form, but it reports built-CLI inline, file, and stdin checks, so the required information is present.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 18ca5ed4-4bab-4573-862d-855e4029d641
Commits
Reviewing files that changed from the base of the PR and between c5fbf1a and f18c2d7.
Files selected for processing: 9
README.md
README.zh.md
cmd/schema/schema.go
cmd/schema/validate.go
cmd/schema/validate_test.go
cmd/schema_validation_test.go
internal/schema/decimal.go
internal/schema/validate.go
internal/schema/validate_test.go
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
size/LLarge or sensitive change across domains or core paths
1 participant
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
Agents can inspect an API method's input schema, but cannot check a proposed input with the CLI before making a request. Add
schema <method> --validatefor offline validation using the same catalog, identity filtering, and command visibility as schema inspection.Changes
@file, and stdin with invocation-scoped FileIO. Resolve the method before consuming input; preserve typed errors and their causes.The input is the emitted
inputSchemaobject (params/data/file, where declared), not a raw request body. Unknown properties remain allowed; defaults and formats are annotations. Validation neither opens upload paths nor establishes authorization, dangerous-operation confirmation, or server-side acceptance. No dependencies or generated catalog files change.Evidence
Before: the upstream CLI rejected
schema ... --validatewith exit 2 andunknown flag "--validate".After: with isolated configuration and no supplied credentials, all three input sources succeed:
lark-cli schema drive.files.list --validate '{"params":{"page_size":50,"direction":"ASC"}}'{"ok":true,"data":{"schema_path":"drive.files.list","valid":true}}Invalid input:
{"params":{"page_size":201,"direction":"PRIVATE"}}exits 2, leaves stdout empty, and reports/params/directionand/params/page_sizeinerror.paramswithout exposing the supplied enum value.20-second fuzz run passed with 6,402,312 executions. Regression tests cover exact numeric boundaries, nested arrays, duplicate keys, stdin/files, FileIO closure and policy failures, identity/visibility restrictions, catalog failures, and real root envelopes.
Test Plan
make build,make vet,make fmt-check.go mod tidyleavesgo.mod/go.sumunchanged.make quality-gate, based onc5fbf1a52df77d5cb9cac2b1501770b2fb9af7d2.Local race-test invocations:
The full
make unit-testinvocation passed every package exceptextension/command: its generated wrapper binary failed to load with macOSmissing LC_UUID. That package passed separately with the system linker also applied to child builds. Applying that flag globally to the full suite instead breaks existing CGO-disabled cross-platform import checks, so the two runs are reported separately. Clearing agent-detection variables isolates existing agent-header tests. The host Go 1.26 race runtime crashed before test execution. Full integration/live-tenant suites were not run; this feature performs no API calls.Merge Danger
Door: two-way — revert the additive flag and validator; no persisted-state migration.
Blast Radius: schema — new validation behavior and the shared method-resolution helper. Existing inspection, visibility, identity filtering, and typed-error contracts are covered by regressions.
Related Issues
Summary by CodeRabbit
--validateto check method input locally against its schema, without logging in or making API requests.