[GH-ISSUE #7057] [Bug] CLI Markdown formatting renders malformed 0-column tables for arrays of empty objects #4259

Closed
opened 2026-10-31 00:48:11 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @viniciusdsandrade on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/7057

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

CLI

Observed behavior

When formatting an array of empty objects (such as [{}] or [{}, {}]) as Markdown (--format md), formatObjectTable derives an empty list of headers (headers = []) and calls renderTable([], rows). This produces malformed Markdown table syntax:

|  |
||
|  |

In GitHub Flavored Markdown (GFM), a table requires at least one column and a valid delimiter row containing hyphens (|---|). A delimiter row with zero columns (||) is not valid Markdown.

Reproduction

Source-derived check based on src/cli/cliOutputFormatter.ts:

  1. Call formatCliOutput([{}], "md") or renderCliDocument([{}], "md", false).
  2. Observe that isObjectArray([{}]) evaluates to true because every element is a non-null object.
  3. formatObjectTable finds no own keys, leaving headers = [].
  4. renderTable([], [[]]) constructs lines ["| |", "||", "| |"].

Expected behavior

Arrays of empty objects without column keys should be formatted as JSON (for example [{}] or [{},{}]), consistent with how non-tabular arrays and scalar values are rendered in Markdown. isObjectArray should require at least one object in the array to have own keys (value.some((item) => Object.keys(item).length > 0)), and formatObjectTable should fall back to JSON if headers.length === 0.

Impact and scope

CLI output in --format md when filtering or selecting records produces malformed Markdown text if records have no own enumerable properties.

REA version

4c680d099

Runtime and platform

Node.js; all platforms

Target and artifact context

CLI output formatting

Interface

CLI

Earliest failure stage

Transport or result projection

Relevant output or evidence

Source reference on main at 4c680d099:

  • src/cli/cliOutputFormatter.ts: isObjectArray admits [{}] because value.every(...) holds.
  • src/cli/cliOutputFormatter.ts: formatObjectTable collects keys via Object.keys(item), resulting in headers: [] and invalid output | |\n||\n| |.

Analysis or suspected cause

Source-derived reasoning: isObjectArray only checks that every item in the non-empty array is an object, without checking whether any item has columns to display. If no object has keys, a Markdown table cannot be constructed.

Originally created by @viniciusdsandrade on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/7057 ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area CLI ### Observed behavior When formatting an array of empty objects (such as `[{}]` or `[{}, {}]`) as Markdown (`--format md`), `formatObjectTable` derives an empty list of headers (`headers = []`) and calls `renderTable([], rows)`. This produces malformed Markdown table syntax: ``` | | || | | ``` In GitHub Flavored Markdown (GFM), a table requires at least one column and a valid delimiter row containing hyphens (`|---|`). A delimiter row with zero columns (`||`) is not valid Markdown. ### Reproduction Source-derived check based on `src/cli/cliOutputFormatter.ts`: 1. Call `formatCliOutput([{}], "md")` or `renderCliDocument([{}], "md", false)`. 2. Observe that `isObjectArray([{}])` evaluates to `true` because every element is a non-null object. 3. `formatObjectTable` finds no own keys, leaving `headers = []`. 4. `renderTable([], [[]])` constructs lines `["| |", "||", "| |"]`. ### Expected behavior Arrays of empty objects without column keys should be formatted as JSON (for example `[{}]` or `[{},{}]`), consistent with how non-tabular arrays and scalar values are rendered in Markdown. `isObjectArray` should require at least one object in the array to have own keys (`value.some((item) => Object.keys(item).length > 0)`), and `formatObjectTable` should fall back to JSON if `headers.length === 0`. ### Impact and scope CLI output in `--format md` when filtering or selecting records produces malformed Markdown text if records have no own enumerable properties. ### REA version 4c680d099 ### Runtime and platform Node.js; all platforms ### Target and artifact context CLI output formatting ### Interface CLI ### Earliest failure stage Transport or result projection ### Relevant output or evidence Source reference on main at 4c680d099: - `src/cli/cliOutputFormatter.ts`: `isObjectArray` admits `[{}]` because `value.every(...)` holds. - `src/cli/cliOutputFormatter.ts`: `formatObjectTable` collects keys via `Object.keys(item)`, resulting in `headers: []` and invalid output `| |\n||\n| |`. ### Analysis or suspected cause Source-derived reasoning: `isObjectArray` only checks that every item in the non-empty array is an object, without checking whether any item has columns to display. If no object has keys, a Markdown table cannot be constructed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4259
No description provided.