{"record":{"id":"cab71bf9c2d49ef6","repo":"t8y2/dbx","slug":"invalid-payloadbase64-w","errorCode":null,"errorMessage":"invalid payloadBase64: %w","messagePattern":"invalid payloadBase64: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/helpers.go","lineNumber":120,"sourceCode":"\t\tswitch typed := value.(type) {\n\t\tcase bool:\n\t\t\treturn typed\n\t\tcase string:\n\t\t\tparsed, err := strconv.ParseBool(strings.TrimSpace(typed))\n\t\t\tif err == nil {\n\t\t\t\treturn parsed\n\t\t\t}\n\t\t}\n\t}\n\treturn defaultValue\n}\n\nfunc decodePayload(params map[string]any) ([]byte, error) {\n\tencoded := stringValue(params, \"payloadBase64\")\n\tif encoded != \"\" {\n\t\tpayload, err := base64.StdEncoding.DecodeString(encoded)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid payloadBase64: %w\", err)\n\t\t}\n\t\treturn payload, nil\n\t}\n\treturn []byte(stringValue(params, \"payload\", \"payloadText\")), nil\n}\n\nfunc splitAddresses(value string) []string {\n\tfields := strings.FieldsFunc(value, func(char rune) bool {\n\t\treturn char == ';' || char == ',' || char == '\\n' || char == '\\r' || char == '\\t' || char == ' '\n\t})\n\tseen := map[string]struct{}{}\n\tresult := make([]string, 0, len(fields))\n\tfor _, field := range fields {\n\t\taddress := strings.TrimSpace(field)\n\t\tif address == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := seen[address]; ok {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/helpers.go#L102-L138","documentation":"decodePayload decodes the 'payloadBase64' parameter with Go's standard base64 encoder when it is provided; if the string is not valid standard base64, sendMessage fails with 'invalid payloadBase64: <decode error>'. The driver only falls back to plain 'payload'/'payloadText' when payloadBase64 is absent or empty, so a present-but-invalid value always aborts the send.","triggerScenarios":"Calling sendMessage with payloadBase64 containing whitespace, URL-safe base64 (-, _) without padding fixes, data-URI prefixes like 'data:text/plain;base64,', untrimmed newlines, or truncated strings.","commonSituations":"Encoding with URL-safe base64 in another language/service then passing it here; copying a base64 blob that got line-wrapped by an editor or log; prepending a data-URI scheme; a serializer escaping the '+' character to a space in a query string.","solutions":["Re-encode the payload with standard base64 (with padding) and pass the exact string.","Strip whitespace/newlines and any 'data:...;base64,' prefix before passing.","If your source is URL-safe base64, convert it to standard encoding (replace '-'/'+' and '_'/'/', re-pad).","Alternatively drop payloadBase64 and pass the raw text via 'payload' or 'payloadText'."],"exampleFix":"// before\nparams := map[string]any{\"payloadBase64\": \"data:application/json;base64,eyJhIjox\"}\n// after\nencoded := base64.StdEncoding.EncodeToString([]byte(`{\"a\":1}`))\nparams := map[string]any{\"payloadBase64\": encoded}","handlingStrategy":"validation","validationCode":"encoded := params[\"payloadBase64\"]\nif s, ok := encoded.(string); ok && s != \"\" {\n    cleaned := strings.Map(func(r rune) rune { if unicode.IsSpace(r) { return -1 }; return r }, s)\n    if _, err := base64.StdEncoding.DecodeString(cleaned); err != nil {\n        return fmt.Errorf(\"payloadBase64 is not valid standard base64: %w\", err)\n    }\n}","typeGuard":"func isStdBase64(s string) bool {\n    if s == \"\" { return false }\n    _, err := base64.StdEncoding.DecodeString(s)\n    return err == nil\n}","tryCatchPattern":"_, err := agent.SendMessage(ctx, params)\nif err != nil && strings.Contains(err.Error(), \"invalid payloadBase64\") {\n    // re-encode payload client-side with base64.StdEncoding and retry once, or switch to 'payloadText'\n}","preventionTips":["Always produce payloadBase64 with the standard encoder (StdEncoding), not URL-safe variants.","Never embed data-URI prefixes or whitespace in the base64 string.","Prefer passing plain text via 'payload'/'payloadText' when content is textual.","Beware HTTP layers that convert '+' to spaces in query strings — send base64 in a JSON body."],"tags":["base64","encoding","validation","rocketmq"],"backgroundTag":"invalid-base64-encoding","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}