fix(output): preserve unstructured list metadata in jq input
- Dominant language
- Go
- Stars
- 605
- Forks
- 47
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 61
Description
## Problem
`unstructuredItemsAsMap` converts an `unstructured.UnstructuredList` into a map containing only `items`. This drops list-level fields from the list's `Object`, including pagination metadata such as:
- `metadata.continue`
- `metadata.resourceVersion`
- `metadata.remainingItemCount`
As a result, equivalent JSON and jq selections behave differently:
```bash
gcx dashboards list --limit 5 --json metadata.continue
gcx dashboards list --limit 5 --jq '.metadata.continue'
```
The JSON selection can return the continuation token, while the jq expression returns `null`. This prevents callers—particularly agents—from reliably paginating when using `--jq`.
## Proposed behavior
Preserve list-level fields from `UnstructuredList.Object` while overlaying the normalized `items` collection. The `Items` field should remain authoritative if `Object` also contains an `items` key.
Apply the behavior consistently to both:
- `unstructured.UnstructuredList`
- `*unstructured.UnstructuredList`
## Acceptance criteria
- `--jq` can access list-level pagination metadata.
- Item traversal such as `.items[]` continues to work.
- The normalized `Items` collection takes precedence over any `items` value in `Object`.
- Value and pointer list inputs behave consistently.
- Regression tests cover pagination metadata, item traversal, and both list forms.
## Context
Claude bot surfaced this behavior while reviewing the jq numeric-normalization changes in #1235 and noted that it predates that PR. This follow-up tracks the recommendation separately.
Contributor guide
Research direction
Start by locating unstructuredItemsAsMap and the existing jq or output tests. Trace how value and pointer unstructured.UnstructuredList inputs are converted, then add regression coverage for pagination metadata, .items[] traversal, and items precedence; the work is done when both list forms produce the same preserved metadata and normalized items.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100