{"record":{"id":"549f96232142e14f","repo":"can1357/oh-my-pi","slug":"codex-security-cloud-response-is-missing-field","errorCode":null,"errorMessage":"Codex Security cloud response is missing ${field}","messagePattern":"Codex Security cloud response is missing (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/security/cloud.ts","lineNumber":113,"sourceCode":"\tclient: CodexSecurityCloudClient;\n\tconfigurationId: string;\n\tstore: SecurityStore;\n\tsignal?: AbortSignal;\n}\n\nfunction object(value: unknown): JsonObject {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new Error(\"Codex Security cloud returned an invalid object\");\n\treturn value as JsonObject;\n}\n\nfunction optionalObject(value: unknown): JsonObject {\n\treturn value && typeof value === \"object\" && !Array.isArray(value) ? (value as JsonObject) : {};\n}\n\nfunction requiredString(value: unknown, field: string): string {\n\tif (typeof value !== \"string\" || value.length === 0)\n\t\tthrow new Error(`Codex Security cloud response is missing ${field}`);\n\treturn value;\n}\n\nfunction optionalString(value: unknown): string | undefined {\n\treturn typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction finiteNumber(value: unknown, fallback = 0): number {\n\treturn typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\nfunction positiveInteger(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value >= 1 ? value : undefined;\n}\n\nfunction normalizeConfiguration(value: unknown): CodexSecurityCloudConfiguration {\n\tconst raw = object(value);\n\tconst scanInput = object(raw.scan_input);","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/security/cloud.ts#L95-L131","documentation":"requiredString() enforces that an expected field in a Codex Security cloud response is a non-empty string. When the field is absent, null, of a wrong type, or an empty string, this error names the missing field. It is a defensive contract check on every cloud response object parsed (ids, configuration, jwt subject, title, cloudId).","triggerScenarios":"Any cloud API call whose parsed response object lacks the required field: scan configuration without id/name, token claims without sub, finding details without title, etc.","commonSituations":"Cloud API schema changes; partially-populated objects from a misconfigured/proxied endpoint; empty-string fields returned by a mocked or stub server.","solutions":["Update the client/package to match the current cloud API schema","Inspect the raw response to see which field is actually missing/empty","Verify you are talking to the real cloud endpoint (baseUrl, no mocking stub)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function hasField(obj: Record<string, unknown>, field: string): boolean {\n  return typeof obj[field] === \"string\" && obj[field].length > 0;\n}\nif (!hasField(raw, \"id\")) throw new Error(\"Cloud response missing id\");","typeGuard":"function hasRequiredString(v: unknown, field: string): v is Record<string, string> {\n  return !!v && typeof v === \"object\" && !Array.isArray(v) &&\n    typeof (v as Record<string, unknown>)[field] === \"string\" &&\n    ((v as Record<string, unknown>)[field] as string).length > 0;\n}","tryCatchPattern":"try {\n  const configs = await client.listConfigurations();\n} catch (err) {\n  if (err.message.startsWith(\"Codex Security cloud response is missing\")) {\n    // capture the field name from the message; update client or report API drift\n  } else throw err;\n}","preventionTips":["Keep the client updated with cloud API schema changes","Validate responses at the boundary before downstream use","Test against a fixture mirroring the live API schema"],"tags":["api-response","validation","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}