{"record":{"id":"2a2e6b41bc1c518b","repo":"jlcodes99/cockpit-tools","slug":"messages-empty","errorCode":null,"errorMessage":"messages.empty","messagePattern":"messages\\.empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/useProviderAccountsPage.ts","lineNumber":417,"sourceCode":"\n  const root =\n    parsed && typeof parsed === 'object' && 'data' in parsed\n      ? (parsed as { data?: unknown }).data\n      : parsed;\n\n  if (typeof root === 'string') {\n    return resolveExternalImportBundleItems(root, platformId, messages);\n  }\n\n  if (Array.isArray(root)) {\n    if (root.length === 0) {\n      throw new Error(messages.noItems);\n    }\n    return root;\n  }\n\n  if (!root || typeof root !== 'object') {\n    throw new Error(messages.empty);\n  }\n\n  const provider = (root as { provider?: unknown }).provider;\n  if (typeof provider === 'string' && provider.trim() && provider.trim() !== platformId) {\n    throw new Error(messages.providerMismatch);\n  }\n\n  const items = (root as { items?: unknown }).items;\n  if (Array.isArray(items) && items.length > 0) {\n    return items;\n  }\n\n  if (platformId === 'codex' && isCodexDirectImportItem(root)) {\n    return [root];\n  }\n\n  if (!Array.isArray(items) || items.length === 0) {\n    throw new Error(messages.noItems);","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/hooks/useProviderAccountsPage.ts#L399-L435","documentation":"The bundle unwrapped to something that is neither a string, an array, nor a non-null object (e.g. number, boolean, or null) — there is no structure to extract accounts from, so messages.empty is thrown (line 417).","triggerScenarios":"JSON parses to a primitive or null at the root after envelope unwrapping: e.g. the file contains just 42, true, null, or a quoted plain string that recursively unwraps to a primitive.","commonSituations":"Pasting a bare token value or number instead of a bundle; an export that serialized null; double-encoded JSON where the innermost value is a scalar; wrong file selected.","solutions":["Check the pasted/exported content actually contains an object or array of accounts","Re-export from the source; ensure the payload is the account bundle, not a scalar","If double-encoded, decode once more before importing"],"exampleFix":"// before\nnull\n// after\n{\"items\":[{\"refresh_token\":\"rt_a\"}]}","handlingStrategy":"type-guard","validationCode":"const root: unknown = JSON.parse(content);\nif (!root || typeof root !== 'object') throw new Error('Bundle must be a JSON object or array');","typeGuard":"const isBundleObject = (v: unknown): v is Record<string, unknown> =>\n  !!v && typeof v === 'object' && !Array.isArray(v);","tryCatchPattern":"try {\n  items = resolveExternalImportBundleItems(content, platformId, messages);\n} catch (e) {\n  if (e instanceof Error && e.message === messages.empty) {\n    showExpectedShapeHelp();\n  }\n}","preventionTips":["Verify the export root is an object/array, not a scalar or null","Watch for double-encoded JSON (JSON-in-JSON strings) and decode fully","Select the correct export file, not an unrelated scalar value file"],"tags":["json","import","type-mismatch","empty-input"],"backgroundTag":"empty-import-payload","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}