{"record":{"id":"2f1b9feb8e000957","repo":"apache/beam","slug":"unable-to-json-unmarshal-environment-config-w","errorCode":null,"errorMessage":"unable to json unmarshal --environment_config: %w","messagePattern":"unable to json unmarshal --environment_config: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/translate.go","lineNumber":130,"sourceCode":"\t\tURNWorkerStatus,\n\t\tURNMonitoringInfoShortID,\n\t\tURNBaseVersionGo,\n\t\tURNToString,\n\t\tURNDataSampling,\n\t\tURNSDKConsumingReceivedData,\n\t}\n\treturn append(capabilities, knownStandardCoders()...)\n}\n\n// CreateEnvironment produces the appropriate payload for the type of environment.\nfunc CreateEnvironment(ctx context.Context, urn string, extractEnvironmentConfig func(context.Context) string) (*pipepb.Environment, error) {\n\tvar serializedPayload []byte\n\tswitch urn {\n\tcase URNEnvProcess:\n\t\tconfig := extractEnvironmentConfig(ctx)\n\t\tpayload := &pipepb.ProcessPayload{}\n\t\tif err := protojson.Unmarshal([]byte(config), payload); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to json unmarshal --environment_config: %w\", err)\n\t\t}\n\t\tserializedPayload = protox.MustEncode(payload)\n\tcase URNEnvExternal:\n\t\tconfig := extractEnvironmentConfig(ctx)\n\t\tpayload := &pipepb.ExternalPayload{Endpoint: &pipepb.ApiServiceDescriptor{Url: config}}\n\t\tserializedPayload = protox.MustEncode(payload)\n\tcase URNEnvDocker:\n\t\tfallthrough\n\tdefault:\n\t\tconfig := extractEnvironmentConfig(ctx)\n\t\tpayload := &pipepb.DockerPayload{ContainerImage: config}\n\t\tserializedPayload = protox.MustEncode(payload)\n\t}\n\treturn &pipepb.Environment{\n\t\tUrn:          urn,\n\t\tPayload:      serializedPayload,\n\t\tCapabilities: goCapabilities(),\n\t\tDependencies: []*pipepb.ArtifactInformation{","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/translate.go#L112-L148","documentation":"CreateEnvironment builds the process environment for the pipeline and expects the --environment_config pipeline option to be valid JSON for pipepb.ProcessPayload. protojson.Unmarshal failing means the config string is not valid JSON or does not match the expected message schema. The underlying protojson error is wrapped via %w.","triggerScenarios":"Running with URNEnvProcess where the --environment_config option (fetched by extractEnvironmentConfig from the context/pipeline options) is malformed JSON, empty, or uses fields incompatible with ProcessPayload.","commonSituations":"Hand-written runner invocations passing --environment_config=... with typos, single quotes instead of JSON double quotes, missing config entirely, or SDK/runner version drift where the config schema changed.","solutions":["Validate the --environment_config value is well-formed JSON matching pipepb.ProcessPayload fields (e.g. {\"os\":\"linux\",\"arch\":\"amd64\"}).","Use double quotes and correct casing for field names per protojson rules.","Omit the option if defaults are acceptable — extractEnvironmentConfig presumably yields a default when unset.","Check SDK version compatibility between the runner emitting the config and the Go SDK parsing it."],"exampleFix":"// before\n--environment_config=\"{'os':'linux'}\"\n// after\n--environment_config='{\"os\":\"linux\",\"arch\":\"amd64\"}'","handlingStrategy":"validation","validationCode":"var probe map[string]any\nif err := json.Unmarshal([]byte(envConfig), &probe); err != nil {\n\treturn fmt.Errorf(\"--environment_config is not valid JSON: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n\treturn nil, fmt.Errorf(\"bad --environment_config (%q): %w\", config, err)\n}","preventionTips":["Validate JSON config with a JSON parser before launching pipelines.","Quote JSON correctly in shell (single-quote the whole value).","Pin matching SDK/runner versions."],"tags":["json","unmarshal","config","beam","go"],"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-14T16:17:12.679Z"}