Repository navigation
Conversation
sam-aydev
commented
Oct 12, 2026
- Fixed cross-company data leak: Added tenant_id to the Redis cache key in services/cache.py to ensure isolated caching per client.
- Fixed cent inaccuracies: Replaced float with Decimal in api/v1/dashboard.py to prevent floating-point arithmetic errors in financial totals.
- Fixed March revenue mismatch: Added tzinfo=timezone.utc to datetime bounds in services/reservations.py to prevent local server time from shifting revenues into the wrong month.
- Fixed cross-company data leak: Added tenant_id to the Redis cache key in services/cache.py to ensure isolated caching per client. - Fixed cent inaccuracies: Replaced float with Decimal in api/v1/dashboard.py to prevent floating-point arithmetic errors in financial totals. - Fixed March revenue mismatch: Added tzinfo=timezone.utc to datetime bounds in services/reservations.py to prevent local server time from shifting revenues into the wrong month.
Comment on lines
+19
to
+25
| # total_revenue_float = float(revenue_data['total']) - this causes accuracy loss | ||
|
|
||
| # Convert to Decimal for precise financial math | ||
| total_revenue = Decimal(revenue_data['total']) | ||
| return { | ||
| "property_id": revenue_data['property_id'], | ||
| "total_revenue": total_revenue_float, | ||
| "total_revenue": total_revenue, |
There was a problem hiding this comment.
Bug: Returning a Decimal for total_revenue causes FastAPI under Pydantic v2 to serialize it as a string, violating the frontend numeric contract.
Severity: LOW
Suggested Fix
Cast total_revenue to float before returning it in the API response, or define an explicit Pydantic response model configuring decimal serialization as a float.
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/api/v1/dashboard.py#L19-L25
Potential issue: Returning a `Decimal` instance for `total_revenue` in an endpoint
returning `Dict[str, Any]` causes FastAPI under Pydantic v2 to serialize the value as a
JSON string instead of a number. The frontend TypeScript types define `total_revenue` as
a `number`, breaking the API contract and causing numeric values to be displayed as
quoted strings in raw data views.
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.