{"record":{"id":"1b968d3ae9e53c89","repo":"openai/codex","slug":"expected-servernotification-schema-to-be-an-object","errorCode":null,"errorMessage":"expected ServerNotification schema to be an object","messagePattern":"expected ServerNotification schema to be an object","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/app-server-protocol/src/export.rs","lineNumber":1377,"sourceCode":"            .with_context(|| format!(\"Failed to write JSON schema for {file_stem}\"))?;\n    }\n\n    let namespace = match raw_namespace {\n        Some(\"v1\") | None => None,\n        Some(ns) => Some(ns.to_string()),\n    };\n    Ok(GeneratedSchema {\n        in_v1_dir: raw_namespace == Some(\"v1\"),\n        namespace,\n        logical_name: logical_name.to_string(),\n        value: schema_value,\n    })\n}\n\nfn add_server_notification_emitted_at_to_json_schema(schema: &mut Value) -> Result<()> {\n    let schema = schema\n        .as_object_mut()\n        .ok_or_else(|| anyhow!(\"expected ServerNotification schema to be an object\"))?;\n    schema.insert(\n        \"properties\".to_string(),\n        serde_json::json!({\n            \"emittedAtMs\": {\n                \"description\": \"Unix timestamp (in milliseconds) when app-server emitted this notification.\",\n                \"format\": \"int64\",\n                \"type\": \"integer\"\n            }\n        }),\n    );\n    // Keep this optional in generated client schemas for compatibility with\n    // older app-server versions. New servers still always emit it.\n    Ok(())\n}\n\nfn enforce_numbered_definition_collision_overrides(schema_name: &str, schema: &mut Value) {\n    for defs_key in [\"definitions\", \"$defs\"] {\n        let Some(defs) = schema.get(defs_key).and_then(Value::as_object) else {","sourceCodeStart":1359,"sourceCodeEnd":1395,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/app-server-protocol/src/export.rs#L1359-L1395","documentation":"A build-time assertion inside add_server_notification_emitted_at_to_json_schema: the generated JSON schema for ServerNotification must be a JSON object (map of properties) so an `emittedAt` field can be injected into it for TypeScript export. It fires when the schema generator produced a non-object (e.g. a boolean or bare type reference) for ServerNotification, meaning the protocol type changed in a way the export script no longer expects.","triggerScenarios":"Thrown at codex-rs/app-server-protocol/src/export.rs:1377 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the generated schema value in export.rs and confirm why ServerNotification serializes to a non-object schema (e.g. an untagged alias or a `$ref`-only schema).","Update the TS export (add #[ts] attributes or adjust the type) so ServerNotification generates a proper object schema with properties.","If the injection is obsolete, guard the mutation on as_object_mut() succeeding instead of erroring."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}