{
  "id": "go/grpc-metadata-key-invalid",
  "signature": "rpc error: code = Internal desc = header key \"X-User-ID\" contains value with non-printable ASCII characters",
  "signature_zh": "rpc 错误：code = Internal，desc = 头部键 \"X-User-ID\" 包含不可打印 ASCII 字符的值",
  "regex": "rpc\\ error:\\ code\\ =\\ Internal\\ desc\\ =\\ header\\ key\\ \"X\\-User\\-ID\"\\ contains\\ value\\ with\\ non\\-printable\\ ASCII\\ characters",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "gRPC 元数据键必须为小写 ASCII；值必须为可打印 ASCII。含大写字母的键或含控制字符的值违反规范。",
  "versions": [
    {
      "version": "google.golang.org/grpc 1.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Base64 helps only for binary values when the key ends in -bin; a non-printable value on a non-bin key still fails.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The metadata is malformed deterministically; retries fail identically.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Normalize keys to lowercase and use -bin suffix for binary values:\nmd := metadata.Pairs(\n    \"x-user-id\", userID,\n    \"x-trace-bin\", string(traceBytes),\n)\nctx = metadata.NewOutgoingContext(ctx, md)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Sanitize values before attaching:\nfunc sanitize(s string) string {\n    return strings.Map(func(r rune) rune {\n        if r >= 0x20 && r < 0x7f { return r }\n        return -1\n    }, s)\n}",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}