t8y2/dbx · error

Unsupported value encoding: %s

Error message

Unsupported value encoding: %s

What it means

parseValueObject rejects a value-encoding parameter that is not one of the supported encodings (base64/decoded variants and 'utf8'). The v2 driver only knows how to decode a fixed set of encodings, so any other string is refused before touching the server. Raised from put and keyBytesParam.

Source

Thrown at agents/drivers/etcd2-go/kv.go:457

	}
	return base64.StdEncoding.EncodeToString(bytes)
}

func parseValueObject(value map[string]json.RawMessage) (string, error) {
	if value == nil {
		value = map[string]json.RawMessage{}
	}
	encoding := stringOrDefault(value, "encoding", "utf8")
	data := stringOrDefault(value, "data", "")
	if encoding == "base64" {
		decoded, err := base64.StdEncoding.DecodeString(data)
		if err != nil {
			return "", err
		}
		return string(decoded), nil
	}
	if encoding != "utf8" {
		return "", fmt.Errorf("Unsupported value encoding: %s", encoding)
	}
	return data, nil
}

func stringOrNull(params map[string]json.RawMessage, key string) *string {
	raw := params[key]
	if len(raw) == 0 || string(raw) == "null" {
		return nil
	}
	var value string
	if err := json.Unmarshal(raw, &value); err != nil {
		return nil
	}
	return &value
}

func stringOrDefault(params map[string]json.RawMessage, key string, fallback string) string {
	value := stringOrNull(params, key)

View on GitHub (pinned to c0390bff16)

Solutions

  1. Use one of the supported encoding strings; plain text must be 'utf8' (exact lowercase).
  2. Pre-encode binary data yourself as base64 and use the base64 encoding option instead.
  3. Check the accepted values in parseValueObject in agents/drivers/etcd2-go/kv.go before sending.

Example fix

// before
put({"key": "a2V5", "value": "dmFsdWU=", "encoding": "base85"})
// after
put({"key": "a2V5", "value": "dmFsdWU=", "encoding": "base64"})
Defensive patterns

Strategy: validation

Validate before calling

var allowed = map[string]bool{"utf8": true, "base64": true}
if encoding != "" && !allowed[strings.ToLower(encoding)] { return fmt.Errorf("unsupported encoding %q; use utf8 or base64", encoding) }

Type guard

func validEncoding(e string) bool { switch e { case "utf8", "base64": return true }; return false }

Try / catch

if err := put(params); err != nil && strings.Contains(err.Error(), "Unsupported value encoding") {
    return fmt.Errorf("fix encoding param to utf8 or base64: %w", err)
}

Prevention

When it happens

Trigger: Calling put (or a key-setting method that passes keyBytesParam) with an 'encoding' field whose value is e.g. 'base85', 'UTF-8' (capitalized), 'binary', or any misspelling other than the accepted set ending in 'utf8'.

Common situations: Typo or case mismatch ('UTF-8' vs 'utf8'), assuming other base64 variants are supported, copying an encoding name from a different library's API.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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