{"record":{"id":"068676aa12680a3c","repo":"googleapis/mcp-toolbox","slug":"failed-to-unmarshal-environmentconfig-w","errorCode":null,"errorMessage":"failed to unmarshal environmentConfig: %w","messagePattern":"failed to unmarshal environmentConfig: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/serverlessspark/createbatch/config.go","lineNumber":91,"sourceCode":"\t\t\tDescription:  ymlCfg.Description,\n\t\t\tAuthRequired: ymlCfg.AuthRequired,\n\t\t},\n\t\tType:   ymlCfg.Type,\n\t\tSource: ymlCfg.Source,\n\t}\n\n\tif ymlCfg.RuntimeConfig != nil {\n\t\trc := &dataprocpb.RuntimeConfig{}\n\t\tif err := unmarshalProto(ymlCfg.RuntimeConfig, rc); err != nil {\n\t\t\treturn Config{}, fmt.Errorf(\"failed to unmarshal runtimeConfig: %w\", err)\n\t\t}\n\t\tcfg.RuntimeConfig = rc\n\t}\n\n\tif ymlCfg.EnvironmentConfig != nil {\n\t\tec := &dataprocpb.EnvironmentConfig{}\n\t\tif err := unmarshalProto(ymlCfg.EnvironmentConfig, ec); err != nil {\n\t\t\treturn Config{}, fmt.Errorf(\"failed to unmarshal environmentConfig: %w\", err)\n\t\t}\n\t\tcfg.EnvironmentConfig = ec\n\t}\n\n\treturn cfg, nil\n}\n","sourceCodeStart":73,"sourceCodeEnd":98,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/serverlessspark/createbatch/config.go#L73-L98","documentation":"Same mechanism as the runtimeConfig error but for the environmentConfig section of the createbatch tool config: the YAML-decoded value is JSON-marchaled and parsed with protojson into dataprocpb.EnvironmentConfig. A mismatch with the proto schema (unknown fields, bad types/enums) yields this wrapped error at config load time.","triggerScenarios":"A createbatch tool YAML has an environmentConfig block containing keys not in dataprocpb.EnvironmentConfig (e.g. misspelled ExecutionConfig/Templates/PeripheralsConfig) or values of the wrong type, processed by NewConfig at startup.","commonSituations":"Putting runtime-only fields inside environmentConfig, typos like 'executionconfig', wrong nesting of PeripheralsConfig sub-fields, or using snake_case instead of proto JSON lowerCamelCase names.","solutions":["Read the wrapped protojson error after 'failed to unmarshal environmentConfig:' to locate the bad field","Validate keys against the dataprocpb.EnvironmentConfig schema (executionConfig, peripheralsConfig, networkConfig, etc.)","Use exact lowerCamelCase proto JSON field names and correct nested structure","Move runtime-related fields (properties, serviceAccount) into runtimeConfig where they belong"],"exampleFix":"# before\nenvironmentConfig:\n  execution_config:\n    serviceAccount: sa@proj.iam.gserviceaccount.com\n# after\nenvironmentConfig:\n  executionConfig:\n    serviceAccount: sa@proj.iam.gserviceaccount.com","handlingStrategy":"validation","validationCode":"var ec dataprocpb.EnvironmentConfig\nb, _ := json.Marshal(rawEnvConfig)\nif err := protojson.Unmarshal(b, &ec); err != nil {\n    return fmt.Errorf(\"bad environmentConfig: %w\", err)\n}","typeGuard":"func validEnvironmentConfig(v any) bool {\n    var ec dataprocpb.EnvironmentConfig\n    b, err := json.Marshal(v)\n    return err == nil && protojson.Unmarshal(b, &ec) == nil\n}","tryCatchPattern":"cfg, err := createbatch.NewConfig(ctx, ymlCfg)\nif err != nil && strings.Contains(err.Error(), \"failed to unmarshal environmentConfig\") {\n    log.Fatalf(\"environmentConfig schema mismatch: %v\", err)\n}","preventionTips":["Use exact proto JSON keys: executionConfig, peripheralsConfig, networkConfig","Keep execution-level settings (serviceAccount) under executionConfig, not runtimeConfig","Lint YAML against the Dataproc EnvironmentConfig proto schema in CI"],"tags":["yaml","protobuf","schema-validation","serverlessspark","config"],"backgroundTag":"proto-schema-mismatch","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}