{"record":{"id":"c9b9f937a29691e9","repo":"jackwener/OpenCLI","slug":"jira-issue-key-did-not-return-requested-field","errorCode":null,"errorMessage":"jira issue ${key} did not return requested field ${id}.","messagePattern":"jira issue (.+?) did not return requested field (.+?)\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/jira/shared.js","lineNumber":185,"sourceCode":"function customValueToMarkdown(value) {\n    if (!value) return '';\n    if (typeof value === 'string') return value.trim();\n    if (value && typeof value === 'object' && value.type === 'doc') return adfToMarkdown(value);\n    if (Array.isArray(value)) return value.map(valueName).filter(Boolean).join(', ');\n    return valueName(value);\n}\n\nfunction inlineComments(fields, key, options) {\n    if (options.comments !== undefined) return requirePayloadArray(options.comments, `jira issue ${key} comments`);\n    const commentBlock = requirePayloadObject(fields.comment, `jira issue ${key} comment field`);\n    return requirePayloadArray(commentBlock.comments, `jira issue ${key} comment field comments`);\n}\n\nfunction selectedFieldRows(fields, names, selection, key) {\n    const ids = selection.mode === 'auto' ? Object.keys(fields).sort() : selection.ids;\n    return ids.map((id) => {\n        if (!Object.prototype.hasOwnProperty.call(fields, id)) {\n            throw new CommandExecutionError(`jira issue ${key} did not return requested field ${id}.`);\n        }\n        const name = typeof names[id] === 'string' && names[id].trim() ? names[id].trim() : id;\n        return { id, name, value: fields[id] };\n    });\n}\n\nexport function normalizeJiraIssue(issue, config, options = {}) {\n    const row = requirePayloadObject(issue, 'jira issue');\n    const key = requirePayloadString(row.key, 'issue key', 'jira issue');\n    const fields = requirePayloadObject(row.fields, `jira issue ${key} fields`);\n    const rendered = row.renderedFields && typeof row.renderedFields === 'object' && !Array.isArray(row.renderedFields)\n        ? row.renderedFields\n        : {};\n    const selection = options.selection ?? null;\n    const custom = configuredFieldNames();\n    const includeComments = options.requireNestedCollections !== false && issueSelectionIncludes(selection, 'comment');\n    const includeAttachments = options.requireNestedCollections !== false && issueSelectionIncludes(selection, 'attachment');\n    const includeIssueLinks = options.requireNestedCollections !== false && issueSelectionIncludes(selection, 'issuelinks');","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jira/shared.js#L167-L203","documentation":"CommandExecutionError from `selectedFieldRows` in clis/jira/shared.js:185, thrown while normalizing a fetched issue when one of the explicitly selected --fields ids is absent from the issue's `fields` object (checked with hasOwnProperty, so a null value is fine but a missing key is not). The Jira API omits fields that don't exist on the instance or aren't applicable, so this indicates a mismatch between what you asked for and what the issue carries.","triggerScenarios":"--fields=customfield_99999 where the custom field doesn't exist in that Jira site; requesting a field type not applicable to that issue type (e.g. sprint on a non-software project); a typo'd id; a field removed or renamed after Jira migration.","commonSituations":"Hardcoded customfield ids from another Jira instance (ids differ per site); scripted field lookups after a Cloud/Server migration; atllassian_JIRA_* env vars pointing at non-existent field ids that get requested but dropped.","solutions":["Verify the field id exists on this Jira instance via GET /rest/api/3/field and correct it.","Remove the offending id from --fields, or use --fields=auto to see everything the issue returns.","Note the difference between a null value (OK) and an omitted key (this error) — null fields are returned, missing ones are not.","If migrating between Jira sites, remap customfield ids; they are instance-specific.","Guard scripts: fetch the field list first and intersect it with your desired ids."],"exampleFix":"// before\n--fields=\"summary,customfield_99999\"  // id from old instance\n// after\n--fields=\"summary,customfield_10016\"  // id confirmed via GET /rest/api/3/field","handlingStrategy":"try-catch","validationCode":"// Intersect desired ids with fields that actually exist on the instance:\nconst available = new Set((await fetchFields()).map(f => f.id));\nconst safe = ids.filter(id => available.has(id));\nconst dropped = ids.filter(id => !available.has(id)); // warn about dropped ids","typeGuard":"function issueHasField(issue, id) {\n  return Boolean(issue && issue.fields && Object.prototype.hasOwnProperty.call(issue.fields, id));\n}","tryCatchPattern":"import { CommandExecutionError } from '@jackwener/opencli/errors';\ntry {\n  const issue = await getJiraIssue(key, fields);\n} catch (e) {\n  if (e instanceof CommandExecutionError && /did not return requested field/.test(e.message)) {\n    const id = e.message.match(/field (\\S+)\\.$/)?.[1];\n    console.warn(`Field ${id} missing on this issue/instance; retrying without it.`);\n    return getJiraIssue(key, fields.filter(f => f !== id));\n  }\n  throw e;\n}","preventionTips":["Verify customfield ids against the target instance (GET /rest/api/3/field); ids are instance-specific.","Re-map ids after Jira Cloud/Server migrations.","Prefer --fields=auto when unsure what the issue returns.","Remember null values are valid; only omitted keys trigger this error."],"tags":["jira","api","field-lookup","cli"],"backgroundTag":"missing-response-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}