{"record":{"id":"bcf1b1a204a6ceae","repo":"jackwener/OpenCLI","slug":"label-did-not-include-a-stable-field","errorCode":null,"errorMessage":"${label} did not include a stable ${field}.","messagePattern":"(.+?) did not include a stable (.+?)\\.","errorType":"validation","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/_atlassian/shared.js","lineNumber":262,"sourceCode":"}\n\nexport function requirePayloadObject(value, label) {\n    if (!value || typeof value !== 'object' || Array.isArray(value)) {\n        throw new CommandExecutionError(`${label} returned an unexpected payload shape; expected an object.`);\n    }\n    return value;\n}\n\nexport function requirePayloadArray(value, label) {\n    if (!Array.isArray(value)) {\n        throw new CommandExecutionError(`${label} returned an unexpected payload shape; expected an array.`);\n    }\n    return value;\n}\n\nexport function requirePayloadString(value, field, label) {\n    if (typeof value !== 'string' && typeof value !== 'number') {\n        throw new CommandExecutionError(`${label} did not include a stable ${field}.`);\n    }\n    const s = String(value).trim();\n    if (!s) throw new CommandExecutionError(`${label} did not include a stable ${field}.`);\n    return s;\n}\n\nexport function requireNonEmptyRows(rows, label, hint) {\n    if (!rows.length) throw new EmptyResultError(label, hint);\n    return rows;\n}\n\nexport function parseLimit(value, defaultValue = 20, maxValue = 100, label = 'limit') {\n    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`${label} must be a positive integer`);\n    }\n    if (n > maxValue) {","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/_atlassian/shared.js#L244-L280","documentation":"requirePayloadString throws this when the field that should hold a stable identifier (page id, issue key, etc.) is absent or of an unexpected type (not string/number). The CLI needs a stable key to reference the resource, so it refuses to continue rather than returning a record without one.","triggerScenarios":"API payload omits the id/key field (e.g. expanded fields not requested, or a different object type returned); the field is a nested object ({id:{...}}) instead of a scalar; response came from the wrong endpoint or a deleted/moved resource stub.","commonSituations":"Data Center vs Cloud responses keying IDs differently; requesting search results where some entries (archived, restricted) lack the id field; Atlassian deprecating a field in a newer API version.","solutions":["Inspect the raw response and confirm which field carries the ID; the field name or nesting may differ between Cloud and Data Center.","Re-run with expanded/other fields enabled if the endpoint requires requesting the ID explicitly (e.g. CQL/JQL field lists).","Check whether the resource type returned actually has this identifier (some result types use contentId vs id).","Update the adapter/CLI version if Atlassian renamed the field in a newer REST version."],"exampleFix":"// before (field list omits id in JQL)\nsearchJql('project = DEMO', fields: ['summary'])\n// after\nsearchJql('project = DEMO', fields: ['summary', 'key', 'id'])","handlingStrategy":"validation","validationCode":"function requireId(record, fields = ['id', 'key', 'contentId']) {\n  for (const f of fields) {\n    const v = record?.[f];\n    if (typeof v === 'string' || typeof v === 'number') return String(v);\n  }\n  throw new Error(`Record lacks a stable identifier (looked for: ${fields.join(', ')})`);\n}","typeGuard":"function hasStableId(v) { return (typeof v === 'string' || typeof v === 'number') && String(v).trim() !== ''; }","tryCatchPattern":"try {\n  const rows = await searchCmd(args);\n} catch (e) {\n  if (/did not include a stable/.test(e.message)) {\n    console.error('Response lacked the id/key field — request it explicitly or check deployment/API version.');\n  } else throw e;\n}","preventionTips":["Explicitly request id/key fields in JQL/CQL field lists.","Check Cloud vs Data Center identifier field names (id vs contentId vs key).","Filter out stub/placeholder records before processing.","Keep the adapter updated for field renames in new API versions."],"tags":["validation","payload","missing-field","atlassian","schema"],"backgroundTag":"missing-field-in-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}