Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen Anfängerfreundlich
#4,098 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@tomron arbeitet bereits daran.

Seit 13.10.2026.

  • #4101 von @tomron — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
87/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
cli

Rechercherichtung

Lies pyiceberg/cli/output.py und untersuche JsonOutput.describe_refs() zusammen mit ConsoleOutput.describe_refs(). Ergänze Regressionstests für eine und mehrere Referenzen und führe anschließend die relevanten Output-Tests aus. Fertig ist die Aufgabe, wenn jede Referenz ein JSON-Objekt mit all ihren Aufbewahrungseigenschaften erzeugt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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
Vorherrschende Sprache
Python
Sterne
1.2k
Forks
618
Ø Merge
1 T. 3 Std.
Gemergte PRs (30 T.)
45

Entwicklungsumgebung

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus apache/iceberg-python

Alle Issues in apache/iceberg-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.