fix(cli-generator): apply result extraction to --page-all output - #17622
fix(cli-generator): apply result extraction to --page-all output#17622devin-ai-integration[bot] wants to merge 5 commits into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
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.
| 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())) |
There was a problem hiding this comment.
🔵 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.
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>
0e892ab to
a9d2acc
Compare
Description
Stack 2/5 ("Benchling CLI fixes", split out of #17620). Stacked on #17621.
--page-allemitted raw page envelopes ({"items": [...], "nextToken": "..."}) instead of the extracted items a plain list call prints, so--format csv|tablewere unusable for paginated output.Changes Made
executor.rs: item extraction is now applied per page, before output, by aPageItemsPathdecided once on the first page and reused for every later page:x-fern-paginationor the body has the heuristic next-token property (is_paginated_response); a single-page non-list response under--page-allkeeps its shapemerge_captured_pages)--no-extractskips all of this and returns full page envelopesdiscovery.rs:PaginationConfig::results_path()accessor.fix-page-all-extraction.yml; regeneratedseed/cli/cli-basic-auth.Before/after against a 2-page Benchling mock (
benchling dna-sequence list --page-all --format csv):Testing
PageItemsPathdecide/items (body-relative declared path + return-value, first-page key lock vs. later sibling arrays, null/absent pages, ambiguity),handle_json_responseend-to-end for return-value+results,--no-extract, and non-paginated responses;cargo test --libingenerators/cli/sdkpasses (1974)pnpm seed test --generator cli --fixture cli-basic-auth --skip-scripts --local2/2script-TTY--no-pager,PAGER=cat,--no-extract, and plain single-pagelistLink to Devin session: https://app.devin.ai/sessions/d3e6c0a2eab24903ae7765c8a4c54032
Open in Devin Desktop: https://app.devin.ai/desktop/session/d3e6c0a2eab24903ae7765c8a4c54032?variant=devin