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
- Read the error code to identify the field (e.g. ETCD_USER_REQUIRED) and supply a non-empty string for it.
- Validate inputs at the call boundary: reject empty/whitespace-only strings before calling.
- Fix upstream config/env so the identity field is actually populated (check the env var or secret is set).
- 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
- Check environment variables / secrets for auth identities before constructing requests.
- Use explicit request builders that refuse to serialize empty required fields.
- Keep field names in a shared constants file to avoid case/key mismatches.
- Reject whitespace-only strings, not just empty ones, during pre-validation.
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
- user is required
- lease, ttl, and preserveLease cannot be specified together
- ttl must be a positive integer
- ETCD_WATCH_SCOPE_INVALID
- ETCD_INVALID_ACCESS
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/c392f6e02ede2452.
Report an issue: GitHub.