feat(schema): add ValidateEnums for --validate path#60
Conversation
Add ValidateEnums to check string fields with oneOf/enum constraints against the payload. Called alongside ValidateRequired and ValidateAllOf when --validate is set, giving consistent client-side errors for invalid enum values (e.g. settings.thinking=true) before the API is reached. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds client-side enum validation to the --validate path so that string fields constrained by JSON Schema oneOf (const branches) or enum are rejected early with a clear error, before the request reaches the API.
Changes:
- Add
ValidateEnumsto recursively validate string enum constraints across objects/arrays in payloads. - Wire
ValidateEnumsintoClient.Runalongside existingValidateRequiredandValidateAllOfwhen--validateis enabled. - Expand schema unit tests to cover enum validation behavior (including nested
oneOfand directenumcases).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/schema/schema.go | Adds ValidateEnums implementation and simplifies empty-segment detection in ParseKV. |
| internal/schema/schema_test.go | Adds/updates tests covering enum validation and ParseKV behavior with/without enum constraints. |
| internal/api/client.go | Invokes ValidateEnums during --validate and simplifies minResults clamping logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Important Review skippedAuto reviews are disabled on this repository. To trigger a review, include ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Note 🎁 Summarized by CodeRabbit FreeYour organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above. Comment |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Add ValidateEnums to check string fields with oneOf/enum constraints against the payload. Called alongside ValidateRequired and ValidateAllOf when --validate is set, giving consistent client-side errors for invalid enum values (e.g. settings.thinking=true) before the API is reached.