fix(pixiv): migrate user/detail to pixivFetch helper for typed errors#1768
Open
Benjamin-eecs wants to merge 1 commit into
Open
fix(pixiv): migrate user/detail to pixivFetch helper for typed errors#1768Benjamin-eecs wants to merge 1 commit into
Benjamin-eecs wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors Pixiv user and detail CLIs to use a shared fetch helper and adds Vitest coverage for input validation and HTTP error handling.
Changes:
- Replaced inline browser/evaluate pipelines with
funcimplementations usingpixivFetch. - Added Vitest unit tests for
pixiv/userandpixiv/detail(invalid IDs, auth failures, not-found, and success mapping).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| clis/pixiv/user.js | Moves to func + pixivFetch and adds argument validation and mapping logic. |
| clis/pixiv/detail.js | Moves to func + pixivFetch and adds argument validation and mapping logic. |
| clis/pixiv/user.test.js | Adds tests for error handling and user profile field mapping/counting. |
| clis/pixiv/detail.test.js | Adds tests for error handling and illustration detail field mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+42
to
+44
| illusts: typeof b.illusts === 'object' ? Object.keys(b.illusts).length : (b.illusts || 0), | ||
| manga: typeof b.manga === 'object' ? Object.keys(b.manga).length : (b.manga || 0), | ||
| novels: typeof b.novels === 'object' ? Object.keys(b.novels).length : (b.novels || 0), |
Raw Error throws surfaced UNKNOWN code instead of AUTH_REQUIRED / COMMAND_EXEC. Fixes jackwener#1767
0765192 to
4d8a70c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
clis/pixiv/user.jsandclis/pixiv/detail.jshand-rolled their own inlinefetchin the pipelineevaluateblock and threw rawErroron 401/403/404/5xx, surfacingcode: UNKNOWNto agents instead of the typedAUTH_REQUIRED/COMMAND_EXECthatpixivFetchinclis/pixiv/utils.jsprovides and that the sibling commandsillusts.js/download.js/search.jsalready use.Migrate to
func-style adapters that go throughpixivFetch. Also add up-front numeric-ID validation matching the sibling pattern inillusts.js, so malformed IDs fail before hitting the network.ranking.jsis intentionally left for follow-up: it hits/ranking.php?format=jsonwhose response shape isdata.contents, not thedata.bodythatpixivFetchreturns, so the helper needs a small extension before the migration can land cleanly there.Related issue: fixes #1767. Continues the typed-error / silent-sentinel sweep direction from #1611, #1631, #1634.
Type of Change
Checklist
Screenshots / Output
Live before / after on this branch:
opencli pixiv user 999999999999 --format yaml(any nonexistent ID):opencli pixiv detail 12345 --format yaml(404) same swap fromUNKNOWNtoCOMMAND_EXEC. Happy pathsopencli pixiv user 11andopencli pixiv detail 99999999continue to return populated rows on this branch.New
clis/pixiv/user.test.jsandclis/pixiv/detail.test.jsmirror theillusts.test.jsshape and coverinvalid id → CommandExecutionError,401 → AuthRequiredError,404 → CommandExecutionError,500 → CommandExecutionError, and the happy-path row mapping. Full pixiv suite: 28/28 pass.