t8y2/dbx · error

ETCD_%s_REQUIRED

ETCD_%s_REQUIRED

Error message

ETCD_%s_REQUIRED

What it means

requiredString validates that a string request field is present and non-empty for auth operations. When the field is missing, null, or the empty string, it throws the typed error ETCD_<FIELD>_REQUIRED with the uppercased field name (e.g. ETCD_USER_REQUIRED). This is an input-validation guard so auth requests never reach etcd with blank identities.

Source

Thrown at agents/drivers/etcd-go/kv.go:627

	var value int64
	if err := json.Unmarshal(raw, &value); err != nil {
		return nil
	}
	return &value
}

func requiredPositiveLong(params map[string]json.RawMessage, field string) (int64, error) {
	value := longOrNull(params, field)
	if value == nil || *value <= 0 {
		return 0, fmt.Errorf("ETCD_INVALID_%s: a positive integer is required", strings.ToUpper(field))
	}
	return *value, nil
}

func requiredString(params map[string]json.RawMessage, field string) (string, error) {
	value := stringOrNull(params, field)
	if value == nil || *value == "" {
		return "", fmt.Errorf("ETCD_%s_REQUIRED", strings.ToUpper(field))
	}
	return *value, nil
}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Read the error code to identify the field (e.g. ETCD_USER_REQUIRED) and supply a non-empty string for it.
  2. Validate inputs at the call boundary: reject empty/whitespace-only strings before calling.
  3. Fix upstream config/env so the identity field is actually populated (check the env var or secret is set).
  4. Verify the request uses the exact JSON field name the driver expects (case-sensitive); a renamed key looks like a missing field.

Example fix

// before
{"user": ""} // ETCD_USER_REQUIRED
// after
{"user": "alice", "password": "s3cret"}
Defensive patterns

Strategy: validation

Validate before calling

func validateRequiredString(params map[string]json.RawMessage, fields ...string) error {
	for _, f := range fields {
		raw, ok := params[f]
		if !ok {
			return fmt.Errorf("field %s is required", f)
		}
		var s string
		if err := json.Unmarshal(raw, &s); err != nil || strings.TrimSpace(s) == "" {
			return fmt.Errorf("field %s must be a non-empty string", f)
		}
	}
	return nil
}
// validateRequiredString(params, "user", "password") before authUserAdd

Type guard

func nonEmptyString(v any) (string, bool) {
	s, ok := v.(string)
	return s, ok && s != ""
}

Try / catch

err := driver.AuthUserAdd(params)
if err != nil {
	var typed interface{ Code() string }
	if errors.As(err, &typed) && strings.HasSuffix(typed.Code(), "_REQUIRED") {
		field := strings.TrimSuffix(strings.TrimPrefix(typed.Code(), "ETCD_"), "_REQUIRED")
		return fmt.Errorf("missing field %s: %w", strings.ToLower(field), err)
	}
	return err
}

Prevention

When it happens

Trigger: authUserAdd, authUserDelete, authUserChangePassword, authUserGrantRevokeRole, authRoleGet, or authRoleAdd called with params missing the required field (e.g. "user" or "role"), set to null, or set to "".

Common situations: Empty username/password from an unset environment variable interpolated into the request; trimming removed whitespace leaving ""; a form/CLI where the user skipped a prompt; refactored client passing wrong JSON key so the expected field is absent.

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/c392f6e02ede2452. Report an issue: GitHub.