Skip to content

isProvablyObjectShapedRoot does not recognize $defs/$ref to typeless object-shaped schemas (e.g. named discriminatedUnion) #3094

Open

Description

@shafiktanbir

In commit 5820f796 (#3081), isProvablyObjectShapedRoot in packages/core-internal/src/util/standardSchema.ts was updated to follow a same-document $ref into $defs / definitions, checking target?.type === 'object'.

When a $defs / definitions entry is a typeless object-shaped schema like z.discriminatedUnion('kind', [z.object(...), z.object(...)]).meta({ id: 'Result' }) (or a union/intersection of objects, or an object schema with properties that omits type: 'object'), target.type === 'object' returns false and wraps structuredContent in { result: ... }, even though the identical schema written inline without .meta({ id }) returns true.

Should isProvablyObjectShapedRoot also check isProvablyObjectShapedRoot(target, {}) when resolving a $ref target?

ss
Image

Activity

  1. added
    v2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions