can1357/oh-my-pi · error
Codex Security cloud returned an invalid object
Error message
Codex Security cloud returned an invalid object
What it means
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.
Source
Thrown at packages/coding-agent/src/security/cloud.ts:103
pendingCommits: number;
finishedCommits: number;
failedCommits: number;
findingCounts: Record<SecuritySeverityLevel, number>;
lastScannedCommit?: string;
lastScannedAt?: string;
updatedAt?: string;
}
export interface PullCodexSecurityCloudResultsInput {
client: CodexSecurityCloudClient;
configurationId: string;
store: SecurityStore;
signal?: AbortSignal;
}
function object(value: unknown): JsonObject {
if (!value || typeof value !== "object" || Array.isArray(value))
throw new Error("Codex Security cloud returned an invalid object");
return value as JsonObject;
}
function optionalObject(value: unknown): JsonObject {
return value && typeof value === "object" && !Array.isArray(value) ? (value as JsonObject) : {};
}
function requiredString(value: unknown, field: string): string {
if (typeof value !== "string" || value.length === 0)
throw new Error(`Codex Security cloud response is missing ${field}`);
return value;
}
function optionalString(value: unknown): string | undefined {
return typeof value === "string" && value.length > 0 ? value : undefined;
}
function finiteNumber(value: unknown, fallback = 0): number {View on GitHub (pinned to 9690622007)
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
Defensive patterns
Strategy: type-guard
Validate before calling
const body = await response.json();
if (!body || typeof body !== "object" || Array.isArray(body)) {
console.error("Unexpected cloud response:", body);
} Type guard
function isJsonObject(v: unknown): v is Record<string, unknown> {
return !!v && typeof v === "object" && !Array.isArray(v);
} Try / catch
try {
const data = await client.listConfigurations();
} catch (err) {
if (err.message.includes("invalid object")) {
// log raw body / check proxy or baseUrl, retry or surface to user
} else throw err;
} Prevention
- Use the official default baseUrl; audit proxy configurations
- Pin/track cloud API versions
- Log raw response bodies on parse failures for diagnosis
When it happens
Trigger: #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.
Common situations: Corporate proxies/intercepting gateways replacing responses; cloud API version drift; hitting a wrong baseUrl that serves different JSON.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Gemini Files API ${context} response is not valid JSON
- Gemini Files API finalize response contains an invalid file.
- Gemini Files API finalize response contains an invalid file.
- Pushbullet upload fields were missing from the destination r
- Discord returned an invalid message response
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/492fe9247934856d.
Report an issue: GitHub.