t8y2/dbx · error

%s is required

Error message

%s is required

What it means

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.

Source

Thrown at agents/drivers/rocketmq/helpers.go:43

	for _, key := range keys {
		if value, ok := params[key]; ok && value != nil {
			switch typed := value.(type) {
			case string:
				return strings.TrimSpace(typed)
			case json.Number:
				return typed.String()
			case float64:
				return strconv.FormatFloat(typed, 'f', -1, 64)
			}
		}
	}
	return ""
}

func requireString(params map[string]any, keys ...string) (string, error) {
	value := stringValue(params, keys...)
	if value == "" {
		return "", fmt.Errorf("%s is required", keys[0])
	}
	return value, nil
}

func intValue(params map[string]any, defaultValue int, keys ...string) int {
	for _, key := range keys {
		value, ok := params[key]
		if !ok || value == nil {
			continue
		}
		switch typed := value.(type) {
		case float64:
			return int(typed)
		case json.Number:
			parsed, err := typed.Int64()
			if err == nil {
				return int(parsed)
			}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Add the named key from the error message to the params map with a non-empty string value.
  2. Fix typos so the key matches one of the accepted aliases for that operation.
  3. Validate/trim input at the caller boundary before invoking the agent operation.
  4. Check upstream config/env that feeds the params map is populated (e.g. group name from a config file).

Example fix

// before
row, err := agent.DescribeConsumerGroup(ctx, map[string]any{})
// after
row, err := agent.DescribeConsumerGroup(ctx, map[string]any{"groupName": "GID_demo"})
Defensive patterns

Strategy: validation

Validate before calling

func requireParams(params map[string]any, keys ...string) error {
    for _, k := range keys {
        v, _ := params[k].(string)
        if strings.TrimSpace(v) == "" {
            return fmt.Errorf("%s is required", k)
        }
    }
    return nil
}
// call before: if err := requireParams(params, "groupName"); err != nil { return err }

Type guard

func hasNonStringString(m map[string]any, key string) bool {
    v, ok := m[key]
    return ok && s, isStr := v.(string), isStr && s != ""
}

Try / catch

row, err := agent.DescribeConsumerGroup(ctx, params)
if err != nil && strings.HasSuffix(err.Error(), " is required") {
    return fmt.Errorf("client input error: %w", err) // do not retry; fix params
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/1115d6880bac394c. Report an issue: GitHub.