🐛 Bug Report: Client.call raises KeyError when error response omits Content-Type

未关闭
#174 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
api, backend

调研方向

Start with the synthetic response reproduction in the issue and inspect appwrite/client.py where Client.call handles the HTTP 502 response. Check how the SDK maps failed responses to AppwriteException, then identify the generator or source that owns this read-only SDK before proposing a change. Done means the missing Content-Type no longer causes KeyError and the original status and body surface through AppwriteException.

由索引模型根据 Issue 内容生成。

描述

👟 Reproduction steps

With SDK 27.0.0, use a synthetic requests.Response and patch requests.request so no network request is made:

from unittest.mock import patch
from requests import Response
from appwrite.client import Client

response = Response()
response.status_code = 502
response.url = "https://cloud.appwrite.io/v1/synthetic"
response._content = b"upstream unavailable"
response.headers = {}  # valid response without a Content-Type header

with patch("appwrite.client.requests.request", return_value=response):
    Client().call("get", "/synthetic")
👍 Expected behavior

The failed HTTP response should surface as AppwriteException (including its status/body where available), consistent with the SDK's documented error behavior.

👎 Actual Behavior

The call raises KeyError: 'Content-Type' from appwrite/client.py while handling the HTTP 502, hiding the original HTTP failure and bypassing AppwriteException.

🎲 Appwrite version

Different version (specify in environment): SDK package 27.0.0; no live Appwrite server was used.

💻 Operating system

Windows

🧱 Your Environment

CPython 3.13, requests 2.34.2. The reproduction patches the request function and uses only a synthetic response; it sends no network request and uses no credentials.

👀 Have you spent some time to check if this issue has been raised before?
  • I checked and didn't find a similar issue. I reviewed the related client-error report #108 and searched existing issues for Content-Type and KeyError AppwriteException; neither reports this missing-header failure.
🏢 Have you read the Code of Conduct?
  • I have read the Code of Conduct

The SDK README describes this repository as auto-generated, and the repository's bot told PR #162 that direct pull requests are not accepted. I'm reporting the reproducible behavior here rather than editing generated code; please route the fix through the appropriate generator/source if applicable.

主要语言
Python
星标
265
派生
68
平均合并
5 小时 2 分钟
30 天内合并 PR
8

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

appwrite/sdk-for-python 的其他 Issue

查看 appwrite/sdk-for-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。