{"record":{"id":"476bcfe8ea6e2165","repo":"angular/angular-cli","slug":"invalid-value-for-argument-key-given-pair","errorCode":null,"errorMessage":"Invalid value for argument: ${key}, Given: '${pair}', Expected key=value pair","messagePattern":"Invalid value for argument: (.+?), Given: '(.+?)', Expected key=value pair","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/command-builder/utilities/json-schema.ts","lineNumber":75,"sourceCode":" * @param keyValuePairOptions A set of options that should be in the form of `key=value`.\n * @param args The parsed arguments.\n * @returns `true` if the options are valid, otherwise an error is thrown.\n */\nfunction checkStringMap(keyValuePairOptions: Set<string>, args: Arguments): boolean {\n  for (const key of keyValuePairOptions) {\n    const value = args[key];\n    if (!Array.isArray(value)) {\n      // Value has been parsed.\n      continue;\n    }\n\n    for (const pair of value) {\n      if (pair === undefined) {\n        continue;\n      }\n\n      if (!pair.includes('=')) {\n        throw new Error(\n          `Invalid value for argument: ${key}, Given: '${pair}', Expected key=value pair`,\n        );\n      }\n    }\n  }\n\n  return true;\n}\n\n/**\n * A Yargs coerce function that converts an array of `key=value` strings to an object.\n * @param value An array of `key=value` strings.\n * @returns An object with the keys and values from the input array.\n */\nfunction coerceToStringMap(\n  value: (string | undefined)[],\n): Record<string, string> | (string | undefined)[] {\n  const stringMap: Record<string, string> = {};","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/command-builder/utilities/json-schema.ts#L57-L93","documentation":"Some CLI options accept an array of key=value strings (e.g. ng g component --export-symbols=... or configuration pair options). checkStringMap validates each provided pair contains '='; a bare value without '=' is rejected with this error naming the argument key.","triggerScenarios":"Passing an option like --some-map foo (no =) or a quoted value where the '=' got swallowed by the shell, when the schema declares the option as a string-array/record type.","commonSituations":"Shell quoting issues (spaces splitting the pair), forgetting '=' in flags like --configuration-key value vs key=value, typos like --env=dev written as --env dev on map-typed options.","solutions":["Use key=value form: --myOption key=value","Quote the whole pair when it contains spaces: --myOption \"key=some value\"","Check the option name in 'ng command --help' to confirm it expects key=value pairs","Fix wrapping scripts that re-split arguments and drop the '='"],"exampleFix":"// before\nng g c card --style scss\n# where option expects pairs\n// after\nng g c card --style=scss  # or --myMap key=value","handlingStrategy":"validation","validationCode":"function validatePairs(key: string, values: string[]): void {\n  for (const pair of values) {\n    if (pair !== undefined && !pair.includes('=')) {\n      throw new Error(`${key} expects key=value, got: ${pair}`);\n    }\n  }\n}\nvalidatePairs('--myOption', parsedArgs);","typeGuard":null,"tryCatchPattern":"try {\n  execSync(`ng ${cmd} ${args.join(' ')}`, { stdio: 'inherit' });\n} catch (e) {\n  if (String(e).includes('Expected key=value pair')) {\n    const pair = String(e).match(/Given: '(.+)'/)?.[1];\n    console.error(`Fix argument to key=value form: ${pair}`);\n  } else throw e;\n}","preventionTips":["Quote args containing spaces: --opt \"key=my value\"","Check --help to see which options are string-array maps","Test scripts with shellcheck to catch quoting bugs"],"tags":["angular-cli","arguments","cli-options","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}