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

bug: ListTypeFromJson hits undefined behavior when a list type has no "element"

未关闭 适合新手
#996 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@LuciferYang 已经在做这个了。

开始于 2026年10月10日。

  • #997 来自 @LuciferYang —— 未关闭

评估

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

调研方向

从 src/iceberg/json_serde.cc 中的 ListTypeFromJson 开始,它通过 const 访问器 json[kElement] 读取元素类型。同一文件中的 MapTypeFromJson 已经通过 GetJsonValue 读取 key 和 value,因此为 kElement 复制这一模式。当缺少 "element" 的列表类型对象返回 JsonParseError,而不是触发未定义行为时即完成,可以用 issue 中的复现步骤进行验证。

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

描述

Summary

ListTypeFromJson in src/iceberg/json_serde.cc reads the element type with the const json[kElement] accessor and never checks that the key exists. For a list type object without "element", nlohmann's const operator[] is undefined behavior: with assertions enabled it aborts on JSON_ASSERT(it != m_data.m_value.object->end()), and under NDEBUG it dereferences the end iterator.

Reproduction

auto json = R"({"type":"list","element-id":1,"element-required":true})"_json;
auto result = TypeFromJson(json);
// Debug build: Assertion failed: (it != m_data.m_value.object->end()), function operator[], file json.hpp

Impact

Every list type goes through TypeFromJson, so a schema with a list-typed field that lacks "element" hits this whether the list is top level or nested in a struct, map or list. SchemaFromJson reaches it when parsing table metadata schemas, the add-schema table update, and the REST CreateTableRequest. Per SECURITY-THREAT-MODEL.md catalog-supplied metadata is trusted input, so this is a robustness issue rather than a security one.

Proposed Fix

Read the key with GetJsonValue<nlohmann::json>(json, kElement), the way MapTypeFromJson reads key and value, so a missing key returns JsonParseError.

Raised in https://github.com/apache/iceberg-cpp/pull/982#pullrequestreview-5477946927.

主要语言
C++
星标
226
派生
133
平均合并
3 天 13 小时
30 天内合并 PR
27

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

apache/iceberg-cpp 的其他 Issue

查看 apache/iceberg-cpp 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

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