Skip to content

Fix cache data leak, decimal inaccuracies, and timezone boundaries - #223

Closed
sam-aydev wants to merge 1 commit into
Base360-AI:mainfrom
sam-aydev:main
Closed

sam-aydev wants to merge 1 commit into
Base360-AI:mainfrom
sam-aydev:main

Conversation

@sam-aydev

Copy link
Copy Markdown
  • 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sam-aydev sam-aydev closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant