[PR #10797] fix: remove invalid meta ref from question schema to prevent validati… #13562

Open
opened 2026-02-16 18:18:24 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10797

State: open
Merged: No


Fix: Remove invalid Schema.ref usage in Question schema

Description

This PR fixes a validation error that occurs when using certain providers (like openai_compatible) in opencode v1.1.x.

The Issue

The application was crashing with the following error:

"Schema.ref 'QuestionOption' was set alongside unsupported fields. If a schema node has Schema.ref set, then only description and default can be set alongside it..."

This was caused by the usage of .meta({ ref: "..." }) on Zod schemas for QuestionOption and QuestionInfo. When converted to JSON Schema, this resulted in objects containing both a $ref and other properties (like type, properties, etc.), which is strictly forbidden in standard JSON Schema (pre-2019 drafts) and causes strict validators to fail.

The Fix

I removed the .meta({ ref: ... }) calls from packages/opencode/src/question/index.ts.
This ensures that zod-to-json-schema (or the internal schema generator) inlines the schema definitions correctly instead of creating invalid reference nodes that conflict with their sibling properties.

Verification

  • Checked out the code locally.
  • Reproduced the issue with the original code.
  • Applied the fix.
  • Ran bun run dev -- run "hi" and confirmed that the application now starts and runs successfully without the schema validation error.

Related Issue

Fixes #7791

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10797 **State:** open **Merged:** No --- # Fix: Remove invalid `Schema.ref` usage in Question schema ## Description This PR fixes a validation error that occurs when using certain providers (like `openai_compatible`) in `opencode` v1.1.x. ### The Issue The application was crashing with the following error: > "Schema.ref 'QuestionOption' was set alongside unsupported fields. If a schema node has Schema.ref set, then only description and default can be set alongside it..." This was caused by the usage of `.meta({ ref: "..." })` on Zod schemas for `QuestionOption` and `QuestionInfo`. When converted to JSON Schema, this resulted in objects containing both a `$ref` and other properties (like `type`, `properties`, etc.), which is strictly forbidden in standard JSON Schema (pre-2019 drafts) and causes strict validators to fail. ### The Fix I removed the `.meta({ ref: ... })` calls from `packages/opencode/src/question/index.ts`. This ensures that `zod-to-json-schema` (or the internal schema generator) inlines the schema definitions correctly instead of creating invalid reference nodes that conflict with their sibling properties. ## Verification - Checked out the code locally. - Reproduced the issue with the original code. - Applied the fix. - Ran `bun run dev -- run "hi"` and confirmed that the application now starts and runs successfully without the schema validation error. ## Related Issue Fixes #7791
yindo added the pull-request label 2026-02-16 18:18:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13562