{"record":{"id":"741f18091699f14a","repo":"apache/beam","slug":"base64-decoding-failed","errorCode":null,"errorMessage":"base64 decoding failed","messagePattern":"base64 decoding failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/protox/base64.go","lineNumber":47,"sourceCode":"\t\tpanic(err)\n\t}\n\treturn ret\n}\n\n// EncodeBase64 encodes a proto wrapped in base64.\nfunc EncodeBase64(msg proto.Message) (string, error) {\n\tdata, err := proto.Marshal(msg)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn base64.StdEncoding.EncodeToString(data), nil\n}\n\n// DecodeBase64 decodes a base64 wrapped proto.\nfunc DecodeBase64(data string, ret proto.Message) error {\n\tdecoded, err := base64.StdEncoding.DecodeString(data)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"base64 decoding failed\")\n\t}\n\treturn proto.Unmarshal(decoded, ret)\n}\n","sourceCodeStart":29,"sourceCodeEnd":51,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/protox/base64.go#L29-L51","documentation":"DecodeBase64 decodes a base64 string and unmarshals the result into a proto message. This error wraps a failure of base64.StdEncoding.DecodeString, meaning the input string is not valid standard-alphabet base64.","triggerScenarios":"Calling DecodeBase64 (directly or via DecodeCoderRef, DecodeType, DecodeFn, makeCoder, makeLink, decodeDataflowCustomCoder) with a string containing invalid characters, wrong padding, or URL-safe base64 (- and _ instead of + and /).","commonSituations":"Pasting a URL-safe base64 blob (from a JSON web token or URL parameter) into a config expecting StdEncoding, copy/paste losing padding or adding whitespace/newlines, or manually editing a serialized coder reference.","solutions":["Ensure the input uses standard base64 alphabet with correct padding (strings.TrimSpace first, strip newlines)","If the source emits URL-safe base64, convert it: replace '-' with '+' and '_' with '/' before decoding","Regenerate the encoded value with EncodeBase64 rather than hand-editing"],"exampleFix":"// before\nerr := protox.DecodeBase64(urlSafeB64, msg)\n// after\nfixed := strings.NewReplacer(\"-\", \"+\", \"_\", \"/\").Replace(strings.TrimSpace(urlSafeB64))\nerr := protox.DecodeBase64(fixed, msg)","handlingStrategy":"validation","validationCode":"if _, err := base64.StdEncoding.DecodeString(strings.TrimSpace(s)); err != nil { return fmt.Errorf(\"not valid std base64: %w\", err) }","typeGuard":null,"tryCatchPattern":"if err := protox.DecodeBase64(s, msg); err != nil {\n    var corr base64.CorruptInputError\n    if errors.As(err, &corr) { /* normalize alphabet/padding and retry once */ }\n    return err\n}","preventionTips":["Only produce encoded strings with EncodeBase64; never hand-edit them","Strip whitespace/newlines before decoding pasted values","Know your producer's base64 flavor (std vs URL-safe) and normalize accordingly"],"tags":["base64","decoding","go"],"backgroundTag":"invalid-argument-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}