Repository navigation
Conversation
Comment on lines
+41
to
+51
| timezone_name = property_row.timezone or "UTC" | ||
| zone = ZoneInfo(timezone_name) | ||
|
|
||
| if month is None: | ||
| latest = (await session.execute(text(""" | ||
| SELECT MAX(check_in_date) AS latest | ||
| FROM reservations | ||
| WHERE property_id = :property_id AND tenant_id = :tenant_id | ||
| """), {"property_id": property_id, "tenant_id": tenant_id})).first() | ||
| latest_date = latest.latest if latest else None | ||
| month = latest_date.astimezone(zone).strftime("%Y-%m") if latest_date else datetime.now(zone).strftime("%Y-%m") |
There was a problem hiding this comment.
Bug: ZoneInfo(timezone_name) can raise unhandled ZoneInfoNotFoundError outside the validation try block, causing a 503 instead of a 422 error on invalid database timezones.
Severity: LOW
Suggested Fix
Wrap the ZoneInfo(timezone_name) lookup and latest_date.astimezone(zone) call in a try...except ZoneInfoNotFoundError block and re-raise as a ValueError with an informative message.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: backend/app/services/reservations.py#L41-L51
Potential issue: In `backend/app/services/reservations.py`, `ZoneInfo(timezone_name)` is
initialized outside of a try block at line 42, and `latest_date.astimezone(zone)` is
called at line 51 without exception handling. If an invalid timezone string exists in
the database, `ZoneInfoNotFoundError` is raised directly. Since `ZoneInfoNotFoundError`
subclasses `KeyError` rather than `ValueError`, it bypasses the 422 `ValueError` handler
in `backend/app/api/v1/dashboard.py` and is caught by the generic 503 error handler.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Summary
Decimal.Replace hardcoded Sunset/Ocean demo login and email-based tenant fallback with the parent project’s Supabase authentication and verified company membership flow. Wire Supabase settings into Docker Compose, add ignores for local secrets and generated files,.