{"record":{"id":"072823494c1adf7e","repo":"apache/beam","slug":"error-reading-transform-name-mapping-flag-as-json","errorCode":null,"errorMessage":"error reading --transform_name_mapping flag as JSON","messagePattern":"error reading --transform_name_mapping flag as JSON","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/dataflow/dataflow.go","lineNumber":318,"sourceCode":"\n\tif *flexRSGoal != \"\" {\n\t\tswitch *flexRSGoal {\n\t\tcase \"FLEXRS_UNSPECIFIED\", \"FLEXRS_SPEED_OPTIMIZED\", \"FLEXRS_COST_OPTIMIZED\":\n\t\t\t// valid values\n\t\tdefault:\n\t\t\treturn nil, errors.Errorf(\"invalid flex resource scheduling goal. Got %q; Use --flexrs_goal=(FLEXRS_UNSPECIFIED|FLEXRS_SPEED_OPTIMIZED|FLEXRS_COST_OPTIMIZED)\", *flexRSGoal)\n\t\t}\n\t}\n\tif !streaming && *transformMapping != \"\" {\n\t\treturn nil, errors.New(\"provided transform_name_mapping for a batch pipeline, did you mean to construct a streaming pipeline?\")\n\t}\n\tif !*update && *transformMapping != \"\" {\n\t\treturn nil, errors.New(\"provided transform_name_mapping without setting the --update flag, so the pipeline would not be updated\")\n\t}\n\tvar updateTransformMapping map[string]string\n\tif *transformMapping != \"\" {\n\t\tif err := json.Unmarshal([]byte(*transformMapping), &updateTransformMapping); err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"error reading --transform_name_mapping flag as JSON\")\n\t\t}\n\t}\n\tif *usePublicIPs == *noUsePublicIPs {\n\t\tuseSet := isFlagPassed(\"use_public_ips\")\n\t\tnoUseSet := isFlagPassed(\"no_use_public_ips\")\n\t\t// If use_public_ips was explicitly set but no_use_public_ips was not, use that value\n\t\t// We take the explicit value of no_use_public_ips if it was set but use_public_ips was not.\n\t\tif useSet && !noUseSet {\n\t\t\t*noUsePublicIPs = !*usePublicIPs\n\t\t} else if useSet && noUseSet {\n\t\t\treturn nil, errors.New(\"exactly one of usePublicIPs and noUsePublicIPs must be true, please check that only one is true\")\n\t\t}\n\t}\n\n\thooks.SerializeHooksToOptions()\n\n\texperiments := jobopts.GetExperiments()\n\t// Ensure that we enable the same set of experiments across all SDKs","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/dataflow/dataflow.go#L300-L336","documentation":"getJobOptions parses the --transform_name_mapping flag as a JSON object of transform name mappings used with pipeline update. If json.Unmarshal fails, the raw parse error is wrapped with this message and returned. The flag is only honored when --update is set, and must be a valid JSON string-to-string object.","triggerScenarios":"Running a streaming pipeline update with --update and a --transform_name_mapping value that is not valid JSON (single quotes, unquoted keys, YAML-style indentation, or a non-object JSON value like an array).","commonSituations":"Hand-editing mapping files and introducing syntax errors, shell quoting stripping double quotes, providing a JSON array instead of an object, or copying mappings from older documentation using a different format.","solutions":["Pass a valid JSON object, e.g. --transform_name_mapping='{\"oldName\":\"newName\"}'","Validate with `jq .` or a JSON linter before launching","Fix shell quoting so embedded double quotes are preserved","Remember the flag requires --update; if not updating, remove the flag entirely"],"exampleFix":"// before\n--transform_name_mapping=oldName:newName\n// after\n--transform_name_mapping='{\"oldName\":\"newName\"}'","handlingStrategy":"validation","validationCode":"if transformMapping != \"\" {\n    var m map[string]string\n    if err := json.Unmarshal([]byte(transformMapping), &m); err != nil {\n        return fmt.Errorf(\"--transform_name_mapping is not valid JSON: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil {\n    if strings.Contains(err.Error(), \"--transform_name_mapping\") {\n        log.Fatalf(\"fix transform mapping JSON: %v\", err)\n    }\n}","preventionTips":["Store mappings in a .json file and pass its validated contents","Lint the mapping JSON in CI before pipeline launches","Use single-quoted shell args to preserve double quotes","Only set the flag together with --update"],"tags":["go","dataflow","cli-flag","json"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}