{"record":{"id":"9fbe6b3d4df9564f","repo":"Yeachan-Heo/oh-my-codex","slug":"input-must-be-a-json-object","errorCode":null,"errorMessage":"input must be a JSON object","messagePattern":"input must be a JSON object","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/team.ts","lineNumber":542,"sourceCode":"  const operation = resolveTeamApiOperation(args[0] || '');\n  if (!operation) {\n    throw new Error(`Usage: omx team api <operation> [--input <json>] [--json]\\nSupported operations: ${TEAM_API_OPERATIONS.join(', ')}`);\n  }\n  let input: Record<string, unknown> = {};\n  let json = false;\n  for (let i = 1; i < args.length; i += 1) {\n    const token = args[i];\n    if (token === '--json') {\n      json = true;\n      continue;\n    }\n    if (token === '--input') {\n      const next = args[i + 1];\n      if (!next) throw new Error('Missing value after --input');\n      try {\n        const parsed = JSON.parse(next) as unknown;\n        if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n          throw new Error('input must be a JSON object');\n        }\n        input = parsed as Record<string, unknown>;\n      } catch (error) {\n        throw new Error(`Invalid --input JSON: ${error instanceof Error ? error.message : String(error)}`);\n      }\n      i += 1;\n      continue;\n    }\n    if (token.startsWith('--input=')) {\n      const raw = token.slice('--input='.length);\n      try {\n        const parsed = JSON.parse(raw) as unknown;\n        if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n          throw new Error('input must be a JSON object');\n        }\n        input = parsed as Record<string, unknown>;\n      } catch (error) {\n        throw new Error(`Invalid --input JSON: ${error instanceof Error ? error.message : String(error)}`);","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/team.ts#L524-L560","documentation":"Thrown when the JSON passed via `--input <next>` parses successfully but is not a plain object — it's null, an array, or a primitive. The team API operations require a JSON object as input. Note this message surfaces via the outer catch as 'Invalid --input JSON: input must be a JSON object' because it's thrown inside the try block.","triggerScenarios":"`--input '[1,2]'` (array), `--input '\"str\"'` or `--input 42` (primitive), or `--input null`.","commonSituations":"Users pasting a JSON array from an API response, or a primitive where an object payload is expected; forgetting the surrounding braces.","solutions":["Wrap the payload in an object: pass `{...}` with string keys/values.","Check the target operation's expected input shape and match it as a JSON object.","For arrays, wrap in an object key if the operation supports it, e.g. `--input '{\"items\":[...]}'`."],"exampleFix":"# before\nomx team api update --input '[{\"id\":1}]'\n# after\nomx team api update --input '{\"id\":1}'","handlingStrategy":"type-guard","validationCode":"const parsed = JSON.parse(raw);\nif (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n  console.error('--input must be a JSON object'); process.exit(2);\n}","typeGuard":"const isJsonObject = (v: unknown): v is Record<string, unknown> =>\n  typeof v === 'object' && v !== null && !Array.isArray(v);","tryCatchPattern":"try { await teamApi(args); } catch (e) {\n  if (e instanceof Error && e.message.includes('must be a JSON object')) { /* wrap payload: --input `{\"data\":<raw>}` */ }\n  else throw e;\n}","preventionTips":["Always serialize an object, never an array or scalar, into --input.","Pipe payloads through jq: `--input \"$(echo \"$p\" | jq -c .)\"`."],"tags":["cli","json-validation","argument-validation"],"backgroundTag":"json-schema-type-mismatch","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}