{
  "id": "grpc/compression-dictionary-mismatch",
  "signature": "INTERNAL: compression dictionary mismatch: expected gzip but received deflate",
  "signature_zh": "INTERNAL: 压缩字典不匹配：期望gzip但收到deflate",
  "regex": "INTERNAL: compression dictionary mismatch: expected \\S+ but received \\S+",
  "domain": "grpc",
  "category": "encoding_error",
  "subcategory": null,
  "root_cause": "gRPC message compression algorithm mismatch between client and server: the client sends a message compressed with 'deflate' but the server expects 'gzip', or vice versa, due to incompatible compression configuration.",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端和服务器之间的gRPC消息压缩算法不匹配：客户端发送使用'deflate'压缩的消息，但服务器期望'gzip'，反之亦然，由于压缩配置不兼容。",
  "versions": [
    {
      "version": "gRPC v1.63.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gRPC-Python v1.62.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gRPC-Go v1.64.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Disabling compression entirely on the client side (e.g., 'grpc.default_compression_algorithm=none') may break if the server requires compression; the error changes to 'UNIMPLEMENTED: Decompressor is not installed'.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Switching to a third compression library (e.g., zstd) without updating both sides causes a new mismatch error; both client and server must agree on the algorithm.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Restarting the server with the same configuration doesn't fix the root cause; the mismatch persists until the client's compression algorithm is changed.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Align compression algorithms: set the same compression on both client and server; e.g., in Python: 'grpc.insecure_channel(target, options=[(\"grpc.default_compression_algorithm\", 2)])' (2=gzip) and on server: 'grpc.server(futures.ThreadPoolExecutor(), options=[(\"grpc.default_compression_algorithm\", 2)])'.",
      "success_rate": 0.9,
      "how": "Align compression algorithms: set the same compression on both client and server; e.g., in Python: 'grpc.insecure_channel(target, options=[(\"grpc.default_compression_algorithm\", 2)])' (2=gzip) and on server: 'grpc.server(futures.ThreadPoolExecutor(), options=[(\"grpc.default_compression_algorithm\", 2)])'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use environment variables to override compression: set 'GRPC_DEFAULT_COMPRESSION_ALGORITHM=gzip' on both client and server to enforce consistency, and 'GRPC_DEFAULT_COMPRESSION_LEVEL=1' for low latency.",
      "success_rate": 0.85,
      "how": "Use environment variables to override compression: set 'GRPC_DEFAULT_COMPRESSION_ALGORITHM=gzip' on both client and server to enforce consistency, and 'GRPC_DEFAULT_COMPRESSION_LEVEL=1' for low latency.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement a client-side interceptor to detect and log compression headers: inspect 'grpc-encoding' metadata and adjust the algorithm dynamically if mismatch is detected; fall back to no compression if negotiation fails.",
      "success_rate": 0.75,
      "how": "Implement a client-side interceptor to detect and log compression headers: inspect 'grpc-encoding' metadata and adjust the algorithm dynamically if mismatch is detected; fall back to no compression if negotiation fails.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "对齐压缩算法：在客户端和服务器上设置相同的压缩；例如在Python中：'grpc.insecure_channel(target, options=[(\"grpc.default_compression_algorithm\", 2)])'（2=gzip），服务器上：'grpc.server(futures.ThreadPoolExecutor(), options=[(\"grpc.default_compression_algorithm\", 2)])'。",
    "使用环境变量覆盖压缩：在客户端和服务器上设置'GRPC_DEFAULT_COMPRESSION_ALGORITHM=gzip'以强制一致性，并设置'GRPC_DEFAULT_COMPRESSION_LEVEL=1'以实现低延迟。",
    "实现客户端拦截器检测和记录压缩头部：检查'grpc-encoding'元数据，并在检测到不匹配时动态调整算法；如果协商失败，回退到无压缩。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://grpc.io/docs/guides/compression/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2024-07-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}