{"record":{"id":"b590475beccf915e","repo":"evanw/esbuild","slug":"invalid-what-value","errorCode":null,"errorMessage":"Invalid ${what}: ${value}","messagePattern":"Invalid (.+?): (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/shared/common.ts","lineNumber":16,"sourceCode":"import type * as types from \"./types\"\nimport * as protocol from \"./stdio_protocol\"\nimport { JSON_parse } from \"./uint8array_json_parser\"\n\ndeclare const ESBUILD_VERSION: string\n\nconst quote: (x: string) => string = JSON.stringify\n\nconst buildLogLevelDefault = 'warning'\nconst transformLogLevelDefault = 'silent'\n\nfunction validateAndJoinStringArray(values: string[], what: string): string {\n  const toJoin: string[] = []\n  for (const value of values) {\n    validateStringValue(value, what)\n    if (value.indexOf(',') >= 0) throw new Error(`Invalid ${what}: ${value}`)\n    toJoin.push(value)\n  }\n  return toJoin.join(',')\n}\n\nlet canBeAnything = () => null\n\nlet mustBeBoolean = (value: boolean | undefined): string | null =>\n  typeof value === 'boolean' ? null : 'a boolean'\n\nlet mustBeString = (value: string | undefined): string | null =>\n  typeof value === 'string' ? null : 'a string'\n\nlet mustBeRegExp = (value: RegExp | undefined): string | null =>\n  value instanceof RegExp ? null : 'a RegExp object'\n\nlet mustBeInteger = (value: number | undefined): string | null =>\n  typeof value === 'number' && value === (value | 0) ? null : 'an integer'","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/lib/shared/common.ts#L1-L34","documentation":"esbuild serializes several array-valued options (target, dropLabels, absPaths, resolveExtensions, mainFields, conditions) into a single comma-delimited CLI flag via validateAndJoinStringArray(). A comma inside any element would corrupt that delimited encoding, so such values are rejected at lib/shared/common.ts:16. Each element must also individually be a valid string (validated first).","triggerScenarios":"Passing `target: ['es2015,esnext']`, `mainFields: ['main,browser']`, `conditions: ['import,default']`, or any of the joined-array options with an element whose string value contains a ',' character.","commonSituations":"Typing a comma-separated list as one array element instead of separate elements; generating config by joining strings with ','; copy-pasting a comma-separated value from docs into an array literal.","solutions":["Split the offending element into separate array entries (e.g. ['es2015','esnext'] not ['es2015,esnext']).","If the value legitimately needs a comma (rare), pick a different representation supported by the option.","Sanitize generated config by splitting on ',' before passing."],"exampleFix":"// before\nawait build({ target: ['es2015,esnext'], entryPoints: ['app.ts'] })\n\n// after\nawait build({ target: ['es2015', 'esnext'], entryPoints: ['app.ts'] })","handlingStrategy":"validation","validationCode":"function assertNoCommas(arr, name) {\n  for (const v of arr) {\n    if (typeof v === 'string' && v.includes(',')) {\n      throw new Error(`${name} element must not contain a comma: ${v}`)\n    }\n  }\n  return arr\n}\n// use before build():\nassertNoCommas(options.target ?? [], 'target')\nassertNoCommas(options.mainFields ?? [], 'mainFields')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep each element of target/mainFields/conditions/resolveExtensions/dropLabels/absPaths a single token.","When generating config from comma-separated strings, split(',') first instead of embedding commas.","Add a unit test that asserts no array option element contains ','."],"tags":["config","validation","array-options","cli-flags"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}