fix: fix required management - #9
Conversation
implement [ENG-9690]
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Go | Sep 7, 2026 9:21a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
There was a problem hiding this comment.
🟡 Changes recommended
It introduces a minimum Go version bump that appears out-of-scope for the stated “required management” fix and needs explicit justification or removal due to compatibility impact.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adjusts how required validation rules are interpreted when generating schema required fields, ensuring that required appearing after dive (and within keys/endkeys) constrains elements rather than making the field itself required.
Changes:
- Add
isRequiredRuleto detect only top-levelrequired(pre-dive) for required-field emission. - Update validation rule application so
divedescends into map values (additionalProperties) andkeys/endkeysrules don’t leak onto values. - Update testdata and unit tests to cover optional map semantics with
dive,keys/endkeys, plus bump the minimum Go version ingo.mod/CONTRIBUTING.md.
File summaries
| File | Description |
|---|---|
| testdata/sample.go | Adds a map field exercising omitempty,dive,keys/endkeys required semantics. |
| go.mod | Bumps the module’s Go version to 1.27.1. |
| gen/schema.go | Switches required detection to isRequiredRule for validate/binding tags. |
| gen/internal_test.go | Adds unit tests for map dive/keys behavior and isRequiredRule. |
| gen/gen_test.go | Adds integration-style assertions that map constraints apply to values and the field remains optional. |
| gen/constrain.go | Implements isRequiredRule, map-aware dive descent, and keys/endkeys skipping. |
| CONTRIBUTING.md | Updates documented minimum Go version to 1.27+. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
implement ENG-9690
Pull request
What this PR does
Effect on annotations and output
How it was tested
make testpassesmake lintpassesmake parityrun (if output-affecting) — repo and result: