# rpc error: code = Internal desc = header key "X-User-ID" contains value with non-printable ASCII characters

- **ID:** `go/grpc-metadata-key-invalid`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

gRPC metadata keys must be lowercase ASCII; values must be printable ASCII. A key with uppercase letters or a value containing control characters violates the spec.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| google.golang.org/grpc 1.0+ | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Normalize keys to lowercase and use -bin suffix for binary values:
md := metadata.Pairs(
    "x-user-id", userID,
    "x-trace-bin", string(traceBytes),
)
ctx = metadata.NewOutgoingContext(ctx, md)
   ```
2. **** (85% success)
   ```
   Sanitize values before attaching:
func sanitize(s string) string {
    return strings.Map(func(r rune) rune {
        if r >= 0x20 && r < 0x7f { return r }
        return -1
    }, s)
}
   ```

## Dead Ends

- **** — Base64 helps only for binary values when the key ends in -bin; a non-printable value on a non-bin key still fails. (70% fail)
- **** — The metadata is malformed deterministically; retries fail identically. (95% fail)
