Summary
When columns isn't passed explicitly, render_document() derives the column set solely from the first record's keys, silently dropping any keys that only appear in later records.
Details
lib/python/base_cli/output.py:164 (call site) and :174-177 (_document_columns): [(str(key).upper(), str(key)) for key in records[0]]. If later records in the same records_key list contain keys absent from the first record (e.g. optional/conditional fields), those keys are silently omitted from CSV/TSV/table output for every row, with no warning. render_document has zero functional test coverage — it's referenced only in tests/test_api_stability.py to assert the symbol exists in __all__.
Impact
A real data-loss footgun for exactly the kind of structured/heterogeneous report this function is meant to render, with no test coverage to catch regressions.
Suggested fix
Union the keys across all records (preserving first-seen order) when columns is omitted, or document/validate that all records must share the same shape and raise if they don't.
Summary
When
columnsisn't passed explicitly,render_document()derives the column set solely from the first record's keys, silently dropping any keys that only appear in later records.Details
lib/python/base_cli/output.py:164(call site) and:174-177(_document_columns):[(str(key).upper(), str(key)) for key in records[0]]. If later records in the samerecords_keylist contain keys absent from the first record (e.g. optional/conditional fields), those keys are silently omitted from CSV/TSV/table output for every row, with no warning.render_documenthas zero functional test coverage — it's referenced only intests/test_api_stability.pyto assert the symbol exists in__all__.Impact
A real data-loss footgun for exactly the kind of structured/heterogeneous report this function is meant to render, with no test coverage to catch regressions.
Suggested fix
Union the keys across all records (preserving first-seen order) when
columnsis omitted, or document/validate that all records must share the same shape and raise if they don't.