fix: avoid unsupported array const schemas - #26
Conversation
📝 WalkthroughWalkthroughThe maintenance-plan schema now expresses ChangesSchema validation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/validate-structured-output-schemas`:
- Around line 87-92: Update the requiredChecks validation in the schema
admission logic to require required_checks.type to be "array" and verify
required_checks.items is a mapping before accessing its enum value. Route both
violations through fail() while preserving the existing enum and
minItems/maxItems checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 1321423d-e151-4f47-babe-57b75b8eebda
📒 Files selected for processing (2)
schemas/maintenance-plan.schema.jsonscripts/validate-structured-output-schemas
| required_checks = properties.get("requiredChecks", {}) | ||
| if ( | ||
| required_checks.get("items", {}).get("enum") != REQUIRED_PLAN_CHECKS | ||
| or required_checks.get("minItems") != len(REQUIRED_PLAN_CHECKS) | ||
| or required_checks.get("maxItems") != len(REQUIRED_PLAN_CHECKS) | ||
| ): |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Require the requiredChecks node to remain an array.
This check validates items.enum and the bounds, but not requiredChecks.type. Since validate_node does not enforce array semantics, a malformed schema typed as a non-array could pass this deterministic-admission check. Also guard items with an explicit mapping check so malformed input produces fail() instead of an AttributeError.
Proposed fix
required_checks = properties.get("requiredChecks", {})
if (
- required_checks.get("items", {}).get("enum") != REQUIRED_PLAN_CHECKS
+ not isinstance(required_checks, dict)
+ or required_checks.get("type") != "array"
+ or not isinstance(required_checks.get("items"), dict)
+ or required_checks["items"].get("enum") != REQUIRED_PLAN_CHECKS
or required_checks.get("minItems") != len(REQUIRED_PLAN_CHECKS)
or required_checks.get("maxItems") != len(REQUIRED_PLAN_CHECKS)
):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| required_checks = properties.get("requiredChecks", {}) | |
| if ( | |
| required_checks.get("items", {}).get("enum") != REQUIRED_PLAN_CHECKS | |
| or required_checks.get("minItems") != len(REQUIRED_PLAN_CHECKS) | |
| or required_checks.get("maxItems") != len(REQUIRED_PLAN_CHECKS) | |
| ): | |
| required_checks = properties.get("requiredChecks", {}) | |
| if ( | |
| not isinstance(required_checks, dict) | |
| or required_checks.get("type") != "array" | |
| or not isinstance(required_checks.get("items"), dict) | |
| or required_checks["items"].get("enum") != REQUIRED_PLAN_CHECKS | |
| or required_checks.get("minItems") != len(REQUIRED_PLAN_CHECKS) | |
| or required_checks.get("maxItems") != len(REQUIRED_PLAN_CHECKS) | |
| ): |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/validate-structured-output-schemas` around lines 87 - 92, Update the
requiredChecks validation in the schema admission logic to require
required_checks.type to be "array" and verify required_checks.items is a mapping
before accessing its enum value. Route both violations through fail() while
preserving the existing enum and minItems/maxItems checks.
Summary
constin the maintenance plan schema with a one-item enum arrayconstvaluesRoot cause
The OpenAI Structured Outputs endpoint rejected
requiredChecks.const: ["Script checks"]. The local validator checked its semantic value but did not reject non-scalarconstvalues, so the incompatibility reached production.Verification
./scripts/test.sh(15 tests)70c3d1247aa0abc0c8d598c5da33614b9e2fc778and mise-phpb0e3c11ca08ea82c47b87be57fdee56842d31586sha256:90c3105576ea22db380be2d23a92cb58ca3e9e462eee0963926db7e52ba2c77130367133164