{"record":{"id":"1115d6880bac394c","repo":"t8y2/dbx","slug":"s-is-required-1115d6","errorCode":null,"errorMessage":"%s is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/helpers.go","lineNumber":43,"sourceCode":"\tfor _, key := range keys {\n\t\tif value, ok := params[key]; ok && value != nil {\n\t\t\tswitch typed := value.(type) {\n\t\t\tcase string:\n\t\t\t\treturn strings.TrimSpace(typed)\n\t\t\tcase json.Number:\n\t\t\t\treturn typed.String()\n\t\t\tcase float64:\n\t\t\t\treturn strconv.FormatFloat(typed, 'f', -1, 64)\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}\n\nfunc requireString(params map[string]any, keys ...string) (string, error) {\n\tvalue := stringValue(params, keys...)\n\tif value == \"\" {\n\t\treturn \"\", fmt.Errorf(\"%s is required\", keys[0])\n\t}\n\treturn value, nil\n}\n\nfunc intValue(params map[string]any, defaultValue int, keys ...string) int {\n\tfor _, key := range keys {\n\t\tvalue, ok := params[key]\n\t\tif !ok || value == nil {\n\t\t\tcontinue\n\t\t}\n\t\tswitch typed := value.(type) {\n\t\tcase float64:\n\t\t\treturn int(typed)\n\t\tcase json.Number:\n\t\t\tparsed, err := typed.Int64()\n\t\t\tif err == nil {\n\t\t\t\treturn int(parsed)\n\t\t\t}","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/helpers.go#L25-L61","documentation":"requireString validates that a named parameter exists and is non-empty in the params map, returning '<key> is required' when stringValue finds no value for any of the accepted keys. Nearly every read/write operation of the RocketMQ driver (describeConsumerGroup, deleteConsumerGroup, getSubscriptionGroupConfig, alterSubscriptionGroupConfig, resetConsumerGroupOffsets, getConsumerLag) uses it to enforce mandatory identifiers like 'groupName' or 'topic'. It is an input-validation error, not a broker error.","triggerScenarios":"Calling any of the listed dispatch operations without providing the required key, or providing it as an empty string / wrong type that stringValue cannot coerce (e.g. {\"groupName\": \"\"} or omitting 'topic' for getConsumerLag).","commonSituations":"Typo in the parameter name (e.g. 'group' instead of 'groupName'); building params dynamically from config where the value is empty; forgetting that alias keys still need at least one present; passing null values from an HTTP handler.","solutions":["Add the named key from the error message to the params map with a non-empty string value.","Fix typos so the key matches one of the accepted aliases for that operation.","Validate/trim input at the caller boundary before invoking the agent operation.","Check upstream config/env that feeds the params map is populated (e.g. group name from a config file)."],"exampleFix":"// before\nrow, err := agent.DescribeConsumerGroup(ctx, map[string]any{})\n// after\nrow, err := agent.DescribeConsumerGroup(ctx, map[string]any{\"groupName\": \"GID_demo\"})","handlingStrategy":"validation","validationCode":"func requireParams(params map[string]any, keys ...string) error {\n    for _, k := range keys {\n        v, _ := params[k].(string)\n        if strings.TrimSpace(v) == \"\" {\n            return fmt.Errorf(\"%s is required\", k)\n        }\n    }\n    return nil\n}\n// call before: if err := requireParams(params, \"groupName\"); err != nil { return err }","typeGuard":"func hasNonStringString(m map[string]any, key string) bool {\n    v, ok := m[key]\n    return ok && s, isStr := v.(string), isStr && s != \"\"\n}","tryCatchPattern":"row, err := agent.DescribeConsumerGroup(ctx, params)\nif err != nil && strings.HasSuffix(err.Error(), \" is required\") {\n    return fmt.Errorf(\"client input error: %w\", err) // do not retry; fix params\n}","preventionTips":["Validate required identifiers at the API/CLI boundary before calling driver operations.","Use exact parameter names from the driver's accepted alias keys (e.g. 'groupName', 'topic').","Trim user-supplied strings; empty-after-trim counts as missing.","Build params from typed config structs rather than loose maps."],"tags":["validation","missing-parameter","rocketmq"],"backgroundTag":"missing-required-parameter","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"}