Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

CLI: --output=json list-refs emits one object per retention property instead of per ref

Đang mở Phù hợp với người mới
#4,098 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@tomron đang làm issue này rồi.

Từ ngày 13/10/2026.

  • #4101 của @tomron — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
87/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
cli

Hướng nghiên cứu

Đọc pyiceberg/cli/output.py và kiểm tra JsonOutput.describe_refs() cùng với ConsoleOutput.describe_refs(). Bổ sung kiểm thử hồi quy cho trường hợp một và nhiều tham chiếu, sau đó chạy các kiểm thử output liên quan. Công việc hoàn tất khi mỗi tham chiếu tạo ra một đối tượng JSON chứa tất cả thuộc tính lưu giữ của tham chiếu đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

kind:bug
Apache Iceberg version

None

Please describe the bug 🐞
Apache Iceberg version

main (development)

Please describe the bug

JsonOutput.describe_refs() emits one JSON object for each retention property rather than one object per snapshot reference.

As a result, pyiceberg --output=json list-refs <table> can return three objects for a table containing only one snapshot reference.

Reproduction
from pyiceberg.cli.output import JsonOutput
from pyiceberg.table.refs import SnapshotRefType

JsonOutput().describe_refs([
    (
        "main",
        SnapshotRefType.BRANCH,
        {
            "min_snapshots_to_keep": "1",
            "max_snapshot_age_ms": "432000000",
            "max_ref_age_ms": "forever",
        },
    )
])
Actual output
[
  {"name": "main", "type": "branch", "min_snapshots_to_keep": "1"},
  {"name": "main", "type": "branch", "max_snapshot_age_ms": "432000000"},
  {"name": "main", "type": "branch", "max_ref_age_ms": "forever"}
]
Expected output
[
  {
    "name": "main",
    "type": "branch",
    "min_snapshots_to_keep": "1",
    "max_snapshot_age_ms": "432000000",
    "max_ref_age_ms": "forever"
  }
]
Root cause

In pyiceberg/cli/output.py, JsonOutput.describe_refs() uses a nested list comprehension:

[
    {"name": name, "type": type, detail_key: detail_val}
    for name, type, detail in refs
    for detail_key, detail_val in detail.items()
]

The inner loop creates a separate object for every entry in detail.

This is inconsistent with ConsoleOutput.describe_refs(), which renders one row per reference.

Suggested fix

Construct one dictionary per reference and merge the retention properties into it. Add a regression test ensuring that one input reference produces one complete JSON object, ideally also covering multiple references.

I reproduced the incorrect output by executing the current list-comprehension logic in isolation. I have not yet run the full CLI against a catalog.

Willingness to contribute

I'd be happy to submit a focused fix with regression tests if the proposed JSON structure is correct.

Willingness to contribute
  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time
Ngôn ngữ chính
Python
Star
1.2k
Fork
618
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
45

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/iceberg-python

Tất cả issue của apache/iceberg-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.