Warn instead of crashing when scraper encounters unknown enum values#31
Warn instead of crashing when scraper encounters unknown enum values#31woofer300 wants to merge 2 commits into
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThis PR shifts the error-handling strategy in data transformation and scraping from fail-fast (throw on first unknown value) to graceful degradation (log warning, use sensible default, continue processing). Four enum mapper functions now return fallback values when encountering unknown inputs, and the scraper orchestration allows partial success by logging skipped eateries instead of aborting. ChangesError handling strategy: from fail-fast to graceful degradation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@prisma/scraper.ts`:
- Around line 387-390: After the transform step that currently logs `Skipped
${errors.length} API eatery(ies) due to transform errors`, add a hard-stop guard
that computes the failure rate (errors.length divided by the total number of API
eateries attempted in the transform) and aborts the run when failures are total
or near-total (e.g., failureRate === 1.0 or failureRate >= 0.9). Implement this
by deriving totalAttempts from the array of API eateries passed into the
transform step, calculating failureRate = errors.length / totalAttempts, and
throwing an Error (or calling process.exit(1)) with a clear message if the
threshold is met to prevent proceeding to any destructive snapshot deletes;
otherwise keep the existing warning and continue.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f0bf18c0-c425-4ec4-9443-fa66cf581ba0
📒 Files selected for processing (2)
prisma/mappers.tsprisma/scraper.ts
Overview
The scraper was crashing when Cornell's API changed and returned an unrecognized value (which last time was a new payment method), leaving menus out of date. Unknown enum values now leave warnings instead of crashing the scraper, and fall back to a default value.
Changes Made
Summary by CodeRabbit