{"record":{"id":"a4eb50472c93690e","repo":"t8y2/dbx","slug":"invalid-params-w","errorCode":null,"errorMessage":"invalid params: %w","messagePattern":"invalid params: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/server.go","lineNumber":150,"sourceCode":"\t\t_ = a.client.Close()\n\t}\n\tif a.proxies != nil {\n\t\ta.proxies.Close()\n\t}\n\ta.client = nil\n\ta.proxies = nil\n\ta.connection = connectionConfig{}\n\ta.clusterName = \"\"\n\ta.brokerAddr = \"\"\n}\n\nfunc decodeParams(raw json.RawMessage) (map[string]any, error) {\n\tif len(raw) == 0 || string(raw) == \"null\" {\n\t\treturn map[string]any{}, nil\n\t}\n\tvar params map[string]any\n\tif err := json.Unmarshal(raw, &params); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid params: %w\", err)\n\t}\n\treturn params, nil\n}\n\nfunc normalizeError(err error) string {\n\tif err == nil {\n\t\treturn \"\"\n\t}\n\tmessage := strings.TrimSpace(err.Error())\n\tif message == \"\" {\n\t\treturn \"RocketMQ operation failed\"\n\t}\n\treturn message\n}\n\nfunc okResult() map[string]any {\n\treturn map[string]any{\"ok\": true}\n}","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/server.go#L132-L168","documentation":"decodeParams unmarshals the raw JSON params into map[string]any; empty params or literal null are tolerated as an empty map, but anything that is not a valid JSON object produces this error wrapping the underlying json.Unmarshal failure. It surfaces when the params field is malformed or of the wrong JSON type (e.g. an array, string, or number instead of an object).","triggerScenarios":"Calling any dispatch method with params set to invalid JSON (e.g. '{\"topic\": }'), or a JSON non-object like '[1,2]', '\"topic\"', or '42'.","commonSituations":"Hand-crafted JSON with a syntax error; clients serializing params as an array instead of an object; double-encoded JSON strings (params passed as a quoted string); template interpolation producing invalid JSON.","solutions":["Validate the params JSON with a linter/parser before sending; ensure it is a JSON object","Inspect the wrapped %w error message for the exact JSON syntax offset","Fix the client serialization so params is map/object-shaped, not an array or string","If params are genuinely optional, send null or omit the field rather than empty/garbage text"],"exampleFix":"// before\nparams := \"{topic: demo}\" // invalid JSON\n// after\nparams := `{\"topic\":\"demo\"}`","handlingStrategy":"validation","validationCode":"func validParams(raw string) bool {\n    if raw == \"\" || raw == \"null\" {\n        return true\n    }\n    var m map[string]any\n    return json.Unmarshal([]byte(raw), &m) == nil\n}\n// call validParams(paramsJSON) before invoking the agent","typeGuard":null,"tryCatchPattern":"res, err := agent.Call(ctx, method, json.RawMessage(raw))\nif err != nil && strings.Contains(err.Error(), \"invalid params:\") {\n    var syntaxErr *json.SyntaxTypeError\n    if errors.As(err, &syntaxErr) {\n        log.Printf(\"params JSON malformed: %v\", syntaxErr)\n    }\n}","preventionTips":["Serialize params with encoding/json from a typed struct instead of string concatenation","Validate JSON payloads in CI before dispatching","Always send params as a JSON object, never arrays or bare scalars","Include the underlying json error (the %w wrap) in logs for the exact offset"],"tags":["json","validation","rpc","rocketmq"],"backgroundTag":"invalid-json-params","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}