Skip to content

fix: avoid unsupported array const schemas - #26

Merged
loadinglucian merged 1 commit into
mainfrom
fix/openai-array-const
Jul 28, 2026
Merged

fix: avoid unsupported array const schemas#26
loadinglucian merged 1 commit into
mainfrom
fix/openai-array-const

Conversation

@loadinglucian

@loadinglucian loadinglucian commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace the unsupported array-valued const in the maintenance plan schema with a one-item enum array
  • make the local Structured Outputs validator reject object/array const values
  • keep the schema representation mechanically synchronized with deterministic admission

Root cause

The OpenAI Structured Outputs endpoint rejected requiredChecks.const: ["Script checks"]. The local validator checked its semantic value but did not reject non-scalar const values, so the incompatibility reached production.

Verification

  • ./scripts/test.sh (15 tests)
  • exact-head A00-A20 parity passed against php-bin 70c3d1247aa0abc0c8d598c5da33614b9e2fc778 and mise-php b0e3c11ca08ea82c47b87be57fdee56842d31586
  • report digest: sha256:90c3105576ea22db380be2d23a92cb58ca3e9e462eee0963926db7e52ba2c771
  • real failure reproduced in watcher run 30367133164
  • live watcher rerun required after merge

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The maintenance-plan schema now expresses requiredChecks as a bounded enum array. The validation script rejects non-scalar const values and validates the updated requiredChecks constraints.

Changes

Schema validation

Layer / File(s) Summary
Bounded requiredChecks contract
schemas/maintenance-plan.schema.json
requiredChecks now requires exactly one array item whose value is Script checks.
Validator enforcement
scripts/validate-structured-output-schemas
Schema validation rejects non-scalar const values and checks the requiredChecks enum, minItems, and maxItems constraints.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: fixing unsupported array-valued const schemas.
Description check ✅ Passed The description covers Summary, Root cause, and Verification, which matches the template well enough despite a missing Security and licensing section.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openai-array-const

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 64eb4b7 and 70c3d12.

📒 Files selected for processing (2)
  • schemas/maintenance-plan.schema.json
  • scripts/validate-structured-output-schemas

Comment on lines +87 to +92
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)
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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.

@loadinglucian
loadinglucian merged commit 3ff1656 into main Jul 28, 2026
3 of 4 checks passed
@loadinglucian
loadinglucian deleted the fix/openai-array-const branch July 28, 2026 14:54
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