{"record":{"id":"ff1fb1070cd62f26","repo":"googleapis/mcp-toolbox","slug":"failed-to-unmarshal-runtimeconfig-w","errorCode":null,"errorMessage":"failed to unmarshal runtimeConfig: %w","messagePattern":"failed to unmarshal runtimeConfig: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/serverlessspark/createbatch/config.go","lineNumber":83,"sourceCode":"\n\tif err := decoder.DecodeContext(ctx, &ymlCfg); err != nil {\n\t\treturn Config{}, err\n\t}\n\n\tcfg := Config{\n\t\tConfigBase: tools.ConfigBase{\n\t\t\tName:         name,\n\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":65,"sourceCodeEnd":98,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/serverlessspark/createbatch/config.go#L65-L98","documentation":"When the createbatch tool config includes a runtimeConfig section, it is decoded into dataprocpb.RuntimeConfig via protojson. This error is thrown when the JSON produced from the YAML does not match the RuntimeConfig proto schema — unknown fields, wrong types, or invalid enum values — and the actual protojson error is wrapped after the colon.","triggerScenarios":"A Serverless Spark createbatch tool YAML contains a runtimeConfig block with a field that is not part of dataprocpb.RuntimeConfig (typo, wrong casing) or a value of the wrong type (string where enum/int expected), passed to NewConfig during startup.","commonSituations":"Typos like 'containerImage' instead of 'containerImage' casing issues, using 'region' inside runtimeConfig instead of environmentConfig, wrong types for serviceAccount fields, or fields from an older/newer Dataproc proto version.","solutions":["Read the wrapped protojson error after 'failed to unmarshal runtimeConfig:' to find the offending field","Cross-check the runtimeConfig keys against the dataprocpb.RuntimeConfig schema (ContainerImage, Properties, ServiceAccount, NetworkConfig, etc.)","Fix field names to exact proto JSON names (lowerCamelCase) and correct value types","Remove unknown/unsupported fields from the runtimeConfig block"],"exampleFix":"# before\nruntimeConfig:\n  serviceaccount: my-sa@proj.iam.gserviceaccount.com\n  containerimage: us.gcr.io/img\n# after\nruntimeConfig:\n  serviceAccount: my-sa@proj.iam.gserviceaccount.com\n  containerImage: us.gcr.io/img","handlingStrategy":"validation","validationCode":"// Validate runtimeConfig keys against the known proto JSON names before load\nvar rc dataprocpb.RuntimeConfig\nb, _ := json.Marshal(rawRuntimeConfig)\nif err := protojson.Unmarshal(b, &rc); err != nil {\n    return fmt.Errorf(\"bad runtimeConfig: %w\", err)\n}\n_ = NewConfig(ctx, yml)","typeGuard":"func validRuntimeConfig(v any) bool {\n    var rc dataprocpb.RuntimeConfig\n    b, err := json.Marshal(v)\n    return err == nil && protojson.Unmarshal(b, &rc) == nil\n}","tryCatchPattern":"cfg, err := createbatch.NewConfig(ctx, ymlCfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to unmarshal runtimeConfig\") {\n        log.Fatalf(\"fix runtimeConfig fields per dataprocpb.RuntimeConfig schema: %v\", err)\n    }\n    return err\n}","preventionTips":["Copy field names directly from Google Cloud Dataproc API reference (lowerCamelCase)","Never place runtime-only fields inside environmentConfig or vice versa","Validate YAML with protojson + a sample RuntimeConfig before deploying","Pin the google.golang.org/genproto/dataproc version your docs target"],"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"}