openai/codex · error · Error
outputSchema must be a plain JSON object
Error message
outputSchema must be a plain JSON object
What it means
Error "outputSchema must be a plain JSON object" thrown in openai/codex.
Source
Thrown at sdk/typescript/src/outputSchemaFile.ts:16
import { promises as fs } from "node:fs";
import os from "node:os";
import path from "node:path";
export type OutputSchemaFile = {
schemaPath?: string;
cleanup: () => Promise<void>;
};
export async function createOutputSchemaFile(schema: unknown): Promise<OutputSchemaFile> {
if (schema === undefined) {
return { cleanup: async () => {} };
}
if (!isJsonObject(schema)) {
throw new Error("outputSchema must be a plain JSON object");
}
const schemaDir = await fs.mkdtemp(path.join(os.tmpdir(), "codex-output-schema-"));
const schemaPath = path.join(schemaDir, "schema.json");
const cleanup = async () => {
try {
await fs.rm(schemaDir, { recursive: true, force: true });
} catch {
// suppress
}
};
try {
await fs.writeFile(schemaPath, JSON.stringify(schema), "utf8");
return { schemaPath, cleanup };
} catch (error) {
await cleanup();
throw error;View on GitHub (pinned to 339751715c)
Solutions
- Pass outputSchema as a plain JSON object rather than an array or primitive.
When it happens
Trigger: Thrown at sdk/typescript/src/outputSchemaFile.ts:16 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/48ec8bea97050170.
Report an issue: GitHub.