{"record":{"id":"7d2367a70a450dcd","repo":"jackwener/OpenCLI","slug":"invalid-jira-fields-selection","errorCode":null,"errorMessage":"Invalid Jira --fields selection","messagePattern":"Invalid Jira --fields selection","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/jira/shared.js","lineNumber":64,"sourceCode":"}\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',\n            'Use Jira field ids such as summary, status, or customfield_12345.',\n        );\n    }\n    return { mode: 'selected', ids: [...new Set(parts)] };\n}","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jira/shared.js#L46-L82","documentation":"ArgumentError from `parseIssueFieldSelection` in clis/jira/shared.js:64, raised when the --fields string, after splitting on ',' and trimming, yields no parts or contains an empty entry (e.g. leading/trailing commas or consecutive commas). Every comma-separated entry must be a non-empty field id.","triggerScenarios":"--fields=\"summary,,status\", --fields=\",\", --fields=\" summary, \" with a trailing comma, or whitespace-only entries between commas.","commonSituations":"Hand-editing a field list and leaving a dangling comma; copy-pasting lists with trailing separators; generated lists from a join where a source field was empty.","solutions":["Remove empty entries: write summary,status instead of summary,,status.","Strip trailing commas in your script: raw.replace(/,+$/, '') before passing the value.","Filter empties when building the list programmatically: ids.filter(Boolean).join(',')."],"exampleFix":"// before\n--fields=\"summary,,status\"\n// after\n--fields=\"summary,status\"","handlingStrategy":"validation","validationCode":"function cleanFieldList(raw) {\n  return raw.split(',').map(s => s.trim()).filter(Boolean).join(',');\n}\n// use: --fields=$(cleanFieldList \"$RAW\")","typeGuard":"const isValidFieldList = (s) => typeof s === 'string' && s.split(',').every(p => p.trim() !== '');","tryCatchPattern":"try {\n  await run(['jira', 'issue', key, '--fields', fields]);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message === 'Invalid Jira --fields selection') {\n    console.error('Empty entry in --fields; remove dangling/double commas.');\n  } else throw e;\n}","preventionTips":["Never end a field list with a comma.","Build lists with ids.filter(Boolean).join(',').","Lint scripts that assemble field lists for empty segments."],"tags":["argument-validation","cli","jira","parsing"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}