decolua/9router · error
Item is not an object
Error message
Item is not an object
What it means
The codex bulk-import route iterates the accounts array and validates each entry: it must be a non-null, non-array object. Anything else (null, string, number, array) throws 'Item is not an object'; the error is caught per-item and counted as a failure rather than aborting the whole import.
Source
Thrown at src/app/api/oauth/codex/bulk-import/route.js:59
if (!Array.isArray(accounts) || accounts.length === 0) {
return NextResponse.json(
{ error: "No accounts provided" },
{ status: 400 }
);
}
const results = [];
let success = 0;
let failed = 0;
// SERIAL loop — createProviderConnection reads max(priority) and reorders
// inside a transaction. Parallel calls would race on priority assignment.
for (let i = 0; i < accounts.length; i++) {
const raw = accounts[i];
try {
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
throw new Error("Item is not an object");
}
// Strip server-controlled fields
const {
id: _id,
provider: _provider,
authType: _authType,
createdAt: _createdAt,
updatedAt: _updatedAt,
...item
} = raw;
if (!item.accessToken || typeof item.accessToken !== "string") {
throw new Error("Missing accessToken");
}
// Backfill missing identity fields from JWT claims
const psd = item.providerSpecificData || {};View on GitHub (pinned to 90b52e06ff)
Solutions
- Ensure every element of accounts is a JSON object like {"accessToken": "...", ...}.
- Remove null/placeholder entries from the array before importing.
- If you have bare token strings, wrap each in an object: { accessToken: token }.
Example fix
// before
{ "accounts": ["eyJhbGciOi...", null] }
// after
{ "accounts": [{ "accessToken": "eyJhbGciOi..." }] } Defensive patterns
Strategy: type-guard
Validate before calling
const bad = accounts.findIndex(
(a) => !a || typeof a !== "object" || Array.isArray(a)
);
if (bad !== -1) console.error(`accounts[${bad}] is not an object`); Type guard
const isImportItem = (x) => x !== null && typeof x === "object" && !Array.isArray(x);
Try / catch
try {
const res = await bulkImport(accounts);
} catch (e) {
if (e.message === "Item is not an object") {
console.error("Filter accounts to plain objects and retry");
} else throw e;
} Prevention
- Export/import JSON arrays of objects, never raw token strings
- Remove null placeholders from hand-edited JSON arrays
- Pre-validate the payload shape client-side before POSTing
When it happens
Trigger: POSTing to /api/oauth/codex/bulk-import with accounts containing null, a string (e.g. a raw token instead of an object), an array, or a number at one of the positions.
Common situations: Pasting a JSON array of token strings instead of objects, exporting from another tool with a different shape, a trailing comma producing null in hand-edited JSON, or a shell tool mangling the payload.
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
- Missing accessToken
- A redeem request id is required to consume a Codex reset cre
- Input must be a JSON object or array of objects
- Item is not an object
- Missing access_token / accessToken
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/3a421bb7702b5e1b.
Report an issue: GitHub.