{"record":{"id":"492fe9247934856d","repo":"can1357/oh-my-pi","slug":"codex-security-cloud-returned-an-invalid-object","errorCode":null,"errorMessage":"Codex Security cloud returned an invalid object","messagePattern":"Codex Security cloud returned an invalid object","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/security/cloud.ts","lineNumber":103,"sourceCode":"\tpendingCommits: number;\n\tfinishedCommits: number;\n\tfailedCommits: number;\n\tfindingCounts: Record<SecuritySeverityLevel, number>;\n\tlastScannedCommit?: string;\n\tlastScannedAt?: string;\n\tupdatedAt?: string;\n}\n\nexport interface PullCodexSecurityCloudResultsInput {\n\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 {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/security/cloud.ts#L85-L121","documentation":"The object() helper validates that a decoded Codex Security cloud API response is a non-null, non-array JSON object before any field extraction. If the cloud returns an array, null, or primitive where an object was expected, this error is thrown — i.e. the response shape violates the client's contract.","triggerScenarios":"#request (raw/page/listFindingDetails) receives a 2xx response whose JSON body is not an object — unexpected API change, a proxy/gateway returning a different payload, or an endpoint returning a list at top level.","commonSituations":"Corporate proxies/intercepting gateways replacing responses; cloud API version drift; hitting a wrong baseUrl that serves different JSON.","solutions":["Verify the cloud base URL is the official Codex Security endpoint","Check for proxy/SSO gateways rewriting response bodies","Update the package in case the cloud API changed its response envelope","Capture the raw response body and compare against the expected schema"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"const body = await response.json();\nif (!body || typeof body !== \"object\" || Array.isArray(body)) {\n  console.error(\"Unexpected cloud response:\", body);\n}","typeGuard":"function isJsonObject(v: unknown): v is Record<string, unknown> {\n  return !!v && typeof v === \"object\" && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  const data = await client.listConfigurations();\n} catch (err) {\n  if (err.message.includes(\"invalid object\")) {\n    // log raw body / check proxy or baseUrl, retry or surface to user\n  } else throw err;\n}","preventionTips":["Use the official default baseUrl; audit proxy configurations","Pin/track cloud API versions","Log raw response bodies on parse failures for diagnosis"],"tags":["api-response","validation","network"],"backgroundTag":"schema-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}