omi icon indicating copy to clipboard operation
omi copied to clipboard

Python CLI: pretty renderer crashes on valid scalar and mixed JSON arrays

Open wenbinio opened this issue 2 months ago • 1 comments

Renderer.emit() in sdks/python-cli/omi_cli/output.py sends every list directly to _emit_table(), although that function requires mapping rows. On the current file (Git blob 6ae7e9ff2d51802f82c3692aa6e334d1eca7b444), Renderer(no_color=True).emit(["alpha", "beta"]) raises AttributeError: 'str' object has no attribute 'get', and emit([17, 3.5]) raises TypeError: 'int' object is not iterable. commands/local.py passes arbitrary unwrapped tool results to this renderer through _emit_tool; JSON mode already preserves these valid result shapes. This is a locally reproduced rendering-contract defect, not an observed production API incident or security finding.

Minimal reproduction from the CLI package directory, with no account or network:

from omi_cli.output import Renderer
Renderer(no_color=True).emit(["alpha", "beta"])

The existing coalesce_rows() helper in the same file already preserves mappings, unwraps Pydantic models and wraps scalar values under value. The focused candidate uses it at the shared list boundary rather than adding per-command guards:

 if isinstance(data, list):
-    self._emit_table(data, columns=columns, title=title)
+    self._emit_table(coalesce_rows(data), columns=columns, title=title)

I executed the actual retrieved module after verifying its Git blob hash. Twenty focused pytest checks produce 8 failed / 12 passed before, and 20 passed after. Regressions cover string, numeric, boolean, null, nested and mixed arrays, literal Rich markup, and Pydantic rows. Controls retain JSON array shapes, mapping-column union/selection, empty results and top-level scalar/mapping behaviour. These are local unit-test inputs, not live API records. The full CLI suite, installed command path, repository preflight and PR metadata contracts have not been run; this is not being presented as merge-ready.

Following the contribution guide's invitation to suggest paid work, @josancamon19, would you approve US$25 for the scoped fix, integrated regression tests and one review revision after acceptance and merge? Please also confirm whether the normal PayPal claim can be initiated through this thread or another supported in-platform process, without a separate claim email. Payment details would remain private. No reward, assignment, production impact or payout is assumed.

Prepared and tested by ChatGPT with @wenbinio's authorization; AI-assisted implementation and correspondence, without separate human code review. Searches for scalar-array rendering and coalesce_rows found no matching report; #12960 concerns Rich markup handling, while the SQL-table parsing issues #12988/#13432 are separate.

wenbinio avatar Sep 12 '26 07:09 wenbinio

Working on this. Plan: pass list payloads through existing coalesce_rows() before _emit_table, plus hermetic tests for scalar/mixed arrays and unchanged JSON mode. ETA: PR opened.

Da7em-T avatar Sep 12 '26 10:09 Da7em-T