ComposioHQ/composio · error · JsonSchemaToZodError

Failed to convert JSON Schema to Zod Schema

Error message

Failed to convert JSON Schema to Zod Schema

What it means

jsonSchemaToZodSchema wraps any failure of the underlying jsonSchemaToZod conversion (unsupported keywords, malformed schema) in JsonSchemaToZodError with the original error as cause. The converted schema backs inputZodSchema/parameters validation on tools.

Source

Thrown at ts/packages/core/src/utils/jsonSchema.ts:498

  }
): T {
  try {
    let schema = jsonSchema;
    // Remove all non-required properties from the schema if strict is true
    if (strict && schema) {
      schema = removeNonRequiredProperties(
        schema as {
          type: 'object';
          properties: Record<string, unknown>;
          required?: string[] | undefined;
        }
      );
    }
    // Convert the JSON schema properties to Zod schema
    const zodSchema = jsonSchemaToZod(schema) as T;
    return zodSchema;
  } catch (error) {
    throw new JsonSchemaToZodError('Failed to convert JSON Schema to Zod Schema', {
      cause: error,
    });
  }
}

/**
 * Reason recorded when strict normalization rewrites a schema node. Every
 * rewrite is lossless: the model can still express the same values.
 *
 * - `optional-property-nullable` — a property missing from `required` was
 *   added to it and widened to accept `null`, the emulation of optional
 *   fields that OpenAI structured outputs document.
 * - `unsupported-keyword-stripped` — an annotation keyword the API rejects
 *   (`default`, `examples`) was removed.
 * - `one-of-converted` — `oneOf` (unsupported) became `anyOf`.
 */
export type StrictSchemaChangeReason =
  'optional-property-nullable' | 'unsupported-keyword-stripped' | 'one-of-converted';

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Inspect error.cause for the real conversion failure.
  2. Fix or simplify the offending schema keyword; the converter supports a JSON-Schema subset.
  3. Avoid schema features outside the supported subset (patternProperties with complex patterns, exotic formats, etc.).
Defensive patterns

Strategy: try-catch

Try / catch

try { const z = tool.inputParametersSchema; } catch (e) {
  if (e instanceof JsonSchemaToZodError) console.error(e.cause); // real reason
}

Prevention

When it happens

Trigger: Accessing tool.parameters/inputParametersSchema or executing validation for a tool whose JSON Schema uses constructs the converter cannot map (e.g. unsupported keywords, invalid types, bad $refs).

Common situations: See trigger scenarios.

Related errors


AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28). Data as JSON: /api/errors/35a5be3fd0e875ca. Report an issue: GitHub.