Enhance error handling and update JSON writing logic - #767
Conversation
WalkthroughThe fetch-assets task now writes updated scraper JSON to Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/fetch-assets.test.js (1)
69-80: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the error-reporting fallback itself.
This test proves only that execution does not reject and zip writing is skipped. It would still pass if the catch block logged an empty or incorrect error. Assert that
ui.log.errorreceives the thrownInternalServerErrorwhencontext.errorsis empty.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/fetch-assets.test.js` around lines 69 - 80, Update the test around command.default.run to assert the error-reporting fallback: when mockWriteUpdatedJson rejects with the InternalServerError and context.errors is empty, verify that ui.log.error receives that exact thrown error. Keep the existing non-rejection and mockZipWrite call-count assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/fetch-assets.test.js`:
- Around line 69-80: Update the test around command.default.run to assert the
error-reporting fallback: when mockWriteUpdatedJson rejects with the
InternalServerError and context.errors is empty, verify that ui.log.error
receives that exact thrown error. Keep the existing non-rejection and
mockZipWrite call-count assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 705d4de6-007f-4bf5-952d-72b836eb4731
📒 Files selected for processing (3)
commands/fetch-assets.jstasks/fetch-assets.jstest/fetch-assets.test.js
This pull request improves error handling and file path correctness in the asset fetching workflow, and adds comprehensive tests to ensure the new behaviors. The main changes include updating how errors are reported, ensuring JSON output is written to a file (not a directory), and adding tests to prevent regressions.
Error handling improvements:
commands/fetch-assets.jsto fall back to the thrown error ifcontext.errorsis empty, ensuring more informative error messages.File path handling:
tasks/fetch-assets.jsto write to a file within thejsonDirdirectory (ghost-import.json) instead of the directory itself, preventing file system errors.joinimport fromnode:pathto support correct file path construction.Testing improvements:
test/fetch-assets.test.jsto verify that the JSON file is written to the correct path and to ensure that no zip file is reported if an earlier task fails.