fix: Improved bluesky.py error handling - #99
Conversation
WalkthroughThe pull request modifies error handling and data formatting in the Bluesky router. It replaces a dictionary error response with a proper HTTPException for 404 cases when a disaster is not found, and converts datetime objects to ISO 8601 strings for API serialization. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 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 |
🐛 Version Bump PredictionWhen this PR is merged to 1.49.0 → 1.49.1 ( 💡 How to change the version bump typeThe version bump is determined by your commit messages and PR title:
What I analyzed:
Edit your PR title or commit messages to change the bump type. |
🚀 Preview Deployment Ready!Backend: https://api-pranav-br-157-fullstack-qualit.private.bluerelief.app Commit: 🔐 AuthenticationDemo Login: Click "Google Sign In" → Use demo auth (no Google account needed) ✨ Version Bump PredictionWhen this PR is merged to main, the version will be bumped: 1.49.0 → 1.49.1 (patch) 💡 How to change the version bump type
Preview will be automatically deleted when PR is closed or merged. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
server/routers/bluesky.py (1)
76-90: Improved 404 handling and datetime serialization look good; minor optional polish
- Raising
HTTPException(status_code=404, detail="Disaster not found")is the right FastAPI pattern and fixes the previous “error dict with 200 OK” behavior. This is a behavior change (404 vs 200), so just ensure any existing clients aren’t relying on the old success+error-body contract.- Converting
event_timeviadisaster.event_time.isoformat() if disaster.event_time else Nonealigns with how other datetime fields are serialized and avoids potential JSON encoding issues.If you want a tiny readability bump, you could use FastAPI’s status constant:
-from fastapi import APIRouter, Depends, HTTPException +from fastapi import APIRouter, Depends, HTTPException +from fastapi import status @@ - if not disaster: - raise HTTPException(status_code=404, detail="Disaster not found") + if not disaster: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail="Disaster not found", + )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
server/routers/bluesky.py(2 hunks)
🔇 Additional comments (1)
server/routers/bluesky.py (1)
1-1: HTTPException import is appropriate and matches usageImporting
HTTPExceptionfrom FastAPI is correct here and is used directly inget_disaster; no issues with this change.
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.