{"record":{"id":"2bd429c5be30b7d5","repo":"jackwener/OpenCLI","slug":"jira-fields-must-be-a-comma-separated-string-or","errorCode":null,"errorMessage":"Jira --fields must be a comma-separated string or auto","messagePattern":"Jira --fields must be a comma-separated string or auto","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/jira/shared.js","lineNumber":59,"sourceCode":"    return `${jiraApiPrefix(config)}${resource.startsWith('/') ? resource : `/${resource}`}${params ? queryString(params) : ''}`;\n}\n\nexport async function jiraRequest(config, resource, options = {}) {\n    return atlassianRequest(config, jiraApiPath(config, resource, options.params), options);\n}\n\nfunction configuredFieldNames() {\n    return {\n        acceptanceCriteria: process.env.ATLASSIAN_JIRA_ACCEPTANCE_FIELD?.trim() || '',\n        sprint: process.env.ATLASSIAN_JIRA_SPRINT_FIELD?.trim() || '',\n        storyPoints: process.env.ATLASSIAN_JIRA_STORY_POINTS_FIELD?.trim() || '',\n    };\n}\n\nexport function parseIssueFieldSelection(raw) {\n    if (raw === undefined) return null;\n    if (typeof raw !== 'string') {\n        throw new ArgumentError('Jira --fields must be a comma-separated string or auto');\n    }\n\n    const parts = raw.split(',').map((field) => field.trim());\n    if (parts.length === 0 || parts.some((field) => !field)) {\n        throw new ArgumentError(\n            'Invalid Jira --fields selection',\n            'Use comma-separated field ids without empty entries, for example summary,status,customfield_12345.',\n        );\n    }\n    if (parts.some((field) => field.toLowerCase() === 'auto')) {\n        if (parts.length !== 1) {\n            throw new ArgumentError('Jira --fields auto cannot be combined with other field ids');\n        }\n        return { mode: 'auto' };\n    }\n    if (parts.some((field) => !/^[A-Za-z][A-Za-z0-9_.:-]*$/.test(field))) {\n        throw new ArgumentError(\n            'Invalid Jira field id in --fields',","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jira/shared.js#L41-L77","documentation":"ArgumentError from `parseIssueFieldSelection` in clis/jira/shared.js:59, raised when the --fields value is defined but not a string. The parser only accepts undefined (no selection), a comma-separated string of field ids, or the literal 'auto'. Any other type (number, boolean, object) is rejected before any Jira request is made.","triggerScenarios":"Passing --fields with a non-string value, e.g. --fields=123 (numeric), programmatic invocation passing a number/boolean/array instead of a string into the `selection` option.","commonSituations":"Wrapping the jira CLI in a script that passes parsed YAML/JSON config values straight through; shell quoting stripping quotes so numbers arrive unquoted; templating that interpolates objects.","solutions":["Quote the value: --fields=\"summary,status\" so the shell/CLI receives a string.","In calling code, coerce first: String(raw) before invoking, or pass undefined to use the default field set.","If passing config programmatically, ensure the option value is typeof 'string'."],"exampleFix":"// before\nfields: config.issueFields // 123 (number)\n// after\nfields: config.issueFields == null ? undefined : String(config.issueFields)","handlingStrategy":"validation","validationCode":"function assertFieldsString(raw) {\n  if (raw !== undefined && typeof raw !== 'string') {\n    throw new TypeError('--fields must be a string like \"summary,status\" or \"auto\"');\n  }\n  return raw;\n}","typeGuard":"const isFieldsValue = (v) => v === undefined || typeof v === 'string';","tryCatchPattern":"import { ArgumentError } from '@jackwener/opencli/errors';\ntry {\n  await run(['jira', 'issue', key, '--fields', fields]);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('--fields must be')) {\n    console.error('Quote the value: --fields=\"summary,status\"');\n  } else throw e;\n}","preventionTips":["Always quote --fields in shells: --fields=\"summary,status\".","Coerce config values with String() before passing programmatically.","Pass undefined (omit the flag) to use defaults instead of null/other types."],"tags":["argument-validation","cli","jira","type-error"],"backgroundTag":"invalid-argument-type","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}