Same ghapi version returns different results depending on fastcore version (JSON `null` → empty `AttrDict`)
还没有人认领这个 Issue。
评估
调研方向
从 issue 中的 GhApi 复现开始,比较 fastcore 1.8.16 和 1.11.2 下的响应转换,重点关注报告中的 fastcore.dict2obj 处理。完成标准是:在所有受支持的 fastcore 版本中,GitHub JSON 的 null 值始终保持为 Python None,并通过所示的仓库列表调用验证该行为。
由索引模型根据 Issue 内容生成。
描述
Summary
When using the same ghapi version, the return value of API calls changes depending on the fastcore dependency version.
Specifically, JSON null values from the GitHub REST API (e.g. repository description) are returned as:
Nonewithfastcore==1.8.16- empty
fastcore.basics.AttrDict({}) withfastcore==1.11.2
This breaks the semantic meaning of the API response and causes downstream issues (e.g. database storage, business logic).
Why this is a problem
- GitHub API explicitly defines
description: nullas “no value” - In Python, this should map to
None {}(empty mapping) has a different semantic meaning thanNone- The behavior changes without changing the ghapi version, only by upgrading a dependency
From a user’s perspective, this means:
The same ghapi version produces different API results depending on dependency resolution
This breaks API contract stability and reproducibility.
Environment
| Component | Version |
|---|---|
| ghapi | 1.0.8 |
| fastcore (local) | 1.8.16 |
| fastcore (sam) | 1.11.2 |
| Python | 3.10.19 |
Reproduction Code
from ghapi.core import GhApi
api = GhApi(token="*******", owner="ORG_NAME")
batch = api.repos.list_for_org("ORG_NAME", per_page=1, page=1)
r0 = batch[0]
print("item:", r0.get("description"), type(r0.get("description")))
print("attr:", r0.description, type(r0.description))
print("has key:", "description" in r0)
Actual Results
With fastcore==1.11.2
item: {} <class 'fastcore.basics.AttrDict'>
attr: {} <class 'fastcore.basics.AttrDict'>
has key: True
With fastcore==1.8.16
item: None <class 'NoneType'>
attr: None <class 'NoneType'>
has key: True
Expected Behavior
JSON null values from the GitHub API should consistently map to Python None, regardless of fastcore version.
At minimum, ghapi should:
- Preserve the semantic meaning of
null - Or pin / constrain fastcore versions to avoid silent behavior changes
Additional Notes
- The conversion appears to happen during
fastcore.dict2objprocessing - ghapi currently forwards this behavior directly to users
- This is not a database or SQLAlchemy issue — the value is already
{}immediately after the ghapi call
This behavior change is unexpected, breaking, and difficult to detect, especially in data ingestion pipelines.
I believe this is worth addressing either in ghapi itself or through tighter fastcore integration.
Thanks for your work on ghapi.
- 主要语言
- Python
- 星标
- 687
- 派生
- 69
- 平均合并
- 1 分钟
- 30 天内合并 PR
- 2
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AnswerDotAI/ghapi 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
AnswerDotAI/ghapi#158 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
AnswerDotAI/ghapi#120 ·
-
难度 2/5 1-3 小时 新手友好度 58/100
AnswerDotAI/ghapi#208 ·
-
难度 3/5 1-2 天 新手友好度 35/100
AnswerDotAI/ghapi#186 ·
-
难度 4/5 3-5 天 新手友好度 35/100
AnswerDotAI/ghapi#185 · 1 条评论 · 1 个 reaction ·
查看 AnswerDotAI/ghapi 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
PedestrianDynamics/pyFDS-Evac#199 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
521xueweihan/HelloGitHub#3790 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
sandialabs/atlas-ui-3#978 ·
维护者通常 1 天内回复
-
area: tests perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 72/100
Nitjsefnie-Harness-Commons/daedalus#1255 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
EleutherAI/lm-evaluation-harness#4256 ·
维护者通常 1 天内回复