{"record":{"id":"7324722f302e56d6","repo":"parcel-bundler/parcel","slug":"feature-flag-name-must-be-set-to-true-or-false","errorCode":null,"errorMessage":"Feature flag ${name} must be set to true or false","messagePattern":"Feature flag (.+?) must be set to true or false","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/parcel/src/cli.js","lineNumber":145,"sourceCode":"    parseOptionInt,\n  ],\n  '--reporter <name>': [\n    'additional reporters to run',\n    (val, acc) => {\n      acc.push(val);\n      return acc;\n    },\n    [],\n  ],\n  '--feature-flag <name=value>': [\n    'sets the value of a feature flag',\n    (value, previousValue) => {\n      let [name, val] = value.split('=');\n      if (name in DEFAULT_FEATURE_FLAGS) {\n        let featureFlagValue;\n        if (typeof DEFAULT_FEATURE_FLAGS[name] === 'boolean') {\n          if (val !== 'true' && val !== 'false') {\n            throw new Error(\n              `Feature flag ${name} must be set to true or false`,\n            );\n          }\n          featureFlagValue = val === 'true';\n        }\n        previousValue[name] = featureFlagValue ?? String(val);\n      } else {\n        INTERNAL_ORIGINAL_CONSOLE.warn(\n          `Unknown feature flag ${name} specified, it will be ignored`,\n        );\n      }\n      return previousValue;\n    },\n    {},\n  ],\n};\n\nvar hmrOptions = {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/parcel/src/cli.js#L127-L163","documentation":"Thrown by the Parcel CLI's --feature-flag option parser when a boolean feature flag is given a value other than 'true' or 'false'. The parser splits the input on '=', looks up the flag name in DEFAULT_FEATURE_FLAGS, and if the flag's default type is boolean, strictly requires the value to be the string 'true' or 'false'. Non-boolean flags pass through the raw string value.","triggerScenarios":"Running `parcel build --feature-flag SomeFlag=yes` or `parcel serve --feature-flag SomeFlag=1` or `parcel --feature-flag SomeFlag` (no value). The value.split('=') yields [name, undefined] or [name, 'yes'], and the boolean check fails for any value not exactly 'true' or 'false'.","commonSituations":"Using `1`/`0` instead of `true`/`false` (common in shell scripts). Using `yes`/`no` (common in other CLI tools). Omitting the `=value` entirely. Typo in the value (e.g., `ture` instead of `true`). Case sensitivity issues (`True` vs `true`).","solutions":["Use exactly 'true' or 'false' as the value: `--feature-flag FlagName=true`.","Check DEFAULT_FEATURE_FLAGS to confirm the flag exists and is boolean-typed.","If the flag name is unknown, the CLI warns 'Unknown feature flag' instead of throwing — so verify spelling."],"exampleFix":"// before\n$ parcel build --feature-flag cacheHeaders=1\n// Error: Feature flag cacheHeaders must be set to true or false\n\n// after\n$ parcel build --feature-flag cacheHeaders=true","handlingStrategy":"validation","validationCode":"// Validate feature flag value before passing to CLI\nconst DEFAULT_FEATURE_FLAGS = require('@parcel/core').DEFAULT_FEATURE_FLAGS;\n\nfunction buildFeatureFlagArg(name, value) {\n  if (!(name in DEFAULT_FEATURE_FLAGS)) {\n    console.warn(`Unknown feature flag: ${name}`);\n    return null;\n  }\n  if (typeof DEFAULT_FEATURE_FLAGS[name] === 'boolean') {\n    if (value !== 'true' && value !== 'false') {\n      throw new Error(`Flag ${name} requires 'true' or 'false', got: ${value}`);\n    }\n  }\n  return `--feature-flag ${name}=${value}`;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use 'true' or 'false' literally — not 1/0, yes/no, or True/False.","Check available feature flags in Parcel's documentation or DEFAULT_FEATURE_FLAGS source.","Use shell completion or a wrapper script that validates flag values before passing them to Parcel."],"tags":["cli","feature-flag","argument-parsing","boolean","validation"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}