Skip to content

fix(cli-generator): apply result extraction to --page-all output - #17622

Open
devin-ai-integration[bot] wants to merge 5 commits into
mainfrom
devin/1788370681-stack-2-page-all
Open

fix(cli-generator): apply result extraction to --page-all output#17622
devin-ai-integration[bot] wants to merge 5 commits into
mainfrom
devin/1788370681-stack-2-page-all

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

Stack 2/5 ("Benchling CLI fixes", split out of #17620). Stacked on #17621.

--page-all emitted raw page envelopes ({"items": [...], "nextToken": "..."}) instead of the extracted items a plain list call prints, so --format csv|table were unusable for paginated output.

Changes Made

  • executor.rs: item extraction is now applied per page, before output, by a PageItemsPath decided once on the first page and reused for every later page:
    enum PageItemsPath { Undecided, Body(path), Value, Property(key), None }
    decide(body, output_val, declared_results):
      declared `x-fern-pagination.results`  -> Body(path)   # resolved against the full body, before x-fern-sdk-return-value
      output_val is array                   -> Value        # already extracted
      output_val has exactly 1 array prop   -> Property(k)  # ignores `_`-prefixed / nextPageToken / kind
      otherwise (0 or ≥2 candidates)        -> None         # ambiguous: page left untouched
    items(page): array -> items; absent/null -> [] ; other -> leave page as-is
    
    • only engaged when the op has x-fern-pagination or the body has the heuristic next-token property (is_paginated_response); a single-page non-list response under --page-all keeps its shape
    • runs on the pager/TTY path and the piped/captured path alike, so both emit the same items (the pager path streams one array per page, as it already did for csv/table/jsonl)
    • captured pages are then just concatenated (merge_captured_pages)
    • --no-extract skips all of this and returns full page envelopes
  • discovery.rs: PaginationConfig::results_path() accessor.
  • Changelog fix-page-all-extraction.yml; regenerated seed/cli/cli-basic-auth.

Before/after against a 2-page Benchling mock (benchling dna-sequence list --page-all --format csv):

# before
items,nextToken
"[{""id"":""seq_1""},{""id"":""seq_2""}]",p2
"[{""id"":""seq_3""}]",
# after
id,name
seq_1,a
seq_2,b
seq_3,c

Testing

  • Unit tests: PageItemsPath decide/items (body-relative declared path + return-value, first-page key lock vs. later sibling arrays, null/absent pages, ambiguity), handle_json_response end-to-end for return-value+results, --no-extract, and non-paginated responses; cargo test --lib in generators/cli/sdk passes (1974)
  • pnpm seed test --generator cli --fixture cli-basic-auth --skip-scripts --local 2/2
  • Manual testing against the mock: piped json/csv, script-TTY --no-pager, PAGER=cat, --no-extract, and plain single-page list

Link to Devin session: https://app.devin.ai/sessions/d3e6c0a2eab24903ae7765c8a4c54032
Open in Devin Desktop: https://app.devin.ai/desktop/session/d3e6c0a2eab24903ae7765c8a4c54032?variant=devin


Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@nitpickybot nitpickybot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review Summary

Reasonable fix for --page-all output shape; merge logic is defensive and falls back to raw pages instead of dropping data. Two concerns: the new unit test appears to be placed outside mod tests, and the heuristic key selection can latch onto the wrong array key when the first page's real results are empty but another array field is populated.

  • 🟡 2 warning(s)
  • 🔵 1 suggestion(s)

To request another review, comment /ai-review on this pull request.

Comment thread generators/cli/sdk/src/openapi/executor.rs Outdated
Comment thread generators/cli/sdk/src/openapi/executor.rs Outdated
Some(path) if !path.trim().is_empty() => Some(path.to_string()),
_ => pages
.iter()
.find_map(|p| crate::formatter::extract_items(p).map(|(key, _)| key.to_string()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 suggestion

The heuristic picks the key from the first page that yields a match; if page 1 has {"items": [], "warnings": ["x"]} the heuristic could latch onto warnings and then flatten warnings across all pages, silently discarding real items. Consider preferring sole_shared_array_key (consistent across all pages) before falling back to the single-page heuristic, or at least verifying the chosen key is an array on every page — which the later loop does, but it can't detect that the wrong array was chosen.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment thread generators/cli/sdk/src/openapi/executor.rs Outdated
Base automatically changed from devin/1788370681-stack-1-anytype-default to main September 2, 2026 19:49
willkendall01 and others added 5 commits September 2, 2026 15:49
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…n every output path

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…dule

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@willkendall01
willkendall01 force-pushed the devin/1788370681-stack-2-page-all branch from 0e892ab to a9d2acc Compare September 2, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant