Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Same ghapi version returns different results depending on fastcore version (JSON `null` → empty `AttrDict`)

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

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
api

调研方向

从 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:

  • None with fastcore==1.8.16
  • empty fastcore.basics.AttrDict ({}) with fastcore==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: null as “no value”
  • In Python, this should map to None
  • {} (empty mapping) has a different semantic meaning than None
  • 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.dict2obj processing
  • 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

环境准备

从这里开始

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

AnswerDotAI/ghapi 的其他 Issue

查看 AnswerDotAI/ghapi 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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