Skip to content

render_document() silently drops data for heterogeneous records when columns aren't explicit #146

Description

@codeforester

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.

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions