Repository navigation
outpost: send reducer bucket totals over the WebSocket - #15411
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
1 issue found across 9 files
Confidence score: 3/5
- In
server/polar/outpost/service.py,get_intervalspasses UUID strings from Redis to UUID columns, which asyncpg cannot encode and can make the query fail. Parse the UUID fields before querying.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/polar/outpost/service.py">
<violation number="1" location="server/polar/outpost/service.py:145">
P1: The Redis event contains UUIDs as strings, but `get_intervals` binds `reducer_id` and `customer_id` against UUID columns; asyncpg cannot encode those strings as UUID parameters. Parse the UUID fields before querying so reducer-bucket events can be delivered.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| repository = ReducerBucketRepository.from_session(session) | ||
| intervals = await repository.get_intervals( | ||
| organization.id, | ||
| event["reducer_id"], |
There was a problem hiding this comment.
P1: The Redis event contains UUIDs as strings, but get_intervals binds reducer_id and customer_id against UUID columns; asyncpg cannot encode those strings as UUID parameters. Parse the UUID fields before querying so reducer-bucket events can be delivered.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At server/polar/outpost/service.py, line 145:
<comment>The Redis event contains UUIDs as strings, but `get_intervals` binds `reducer_id` and `customer_id` against UUID columns; asyncpg cannot encode those strings as UUID parameters. Parse the UUID fields before querying so reducer-bucket events can be delivered.</comment>
<file context>
@@ -120,5 +131,37 @@ async def _send_customer_meter(
+ repository = ReducerBucketRepository.from_session(session)
+ intervals = await repository.get_intervals(
+ organization.id,
+ event["reducer_id"],
+ bucket_start,
+ bucket_start + REDUCER_BUCKET_SIZE,
</file context>
There was a problem hiding this comment.
0 issues found across 6 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 11 files (changes from recent commits).
Confidence score: 3/5
get_unsealed_totalsinserver/polar/outpost/service.pycan omit current Redis-only buckets from WebSocket updates untilreducer_bucket.syncruns. Include those pending buckets when calculating totals.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/polar/outpost/service.py">
<violation number="1" location="server/polar/outpost/service.py:178">
P2: `get_unsealed_totals` reads only PostgreSQL, while current buckets remain only in Redis until the delayed `reducer_bucket.sync` runs. Customer-meter updates publish this event during that window, so WebSocket messages omit active-bucket usage; include those Redis values before sending.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
|
||
| count, total, minimum, maximum = await ReducerBucketRepository.from_session( | ||
| session | ||
| ).get_unsealed_totals(organization.id, reducer.id, identities) |
There was a problem hiding this comment.
P2: get_unsealed_totals reads only PostgreSQL, while current buckets remain only in Redis until the delayed reducer_bucket.sync runs. Customer-meter updates publish this event during that window, so WebSocket messages omit active-bucket usage; include those Redis values before sending.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At server/polar/outpost/service.py, line 178:
<comment>`get_unsealed_totals` reads only PostgreSQL, while current buckets remain only in Redis until the delayed `reducer_bucket.sync` runs. Customer-meter updates publish this event during that window, so WebSocket messages omit active-bucket usage; include those Redis values before sending.</comment>
<file context>
@@ -152,30 +128,84 @@ async def _send_reducer_bucket(
+
+ count, total, minimum, maximum = await ReducerBucketRepository.from_session(
+ session
+ ).get_unsealed_totals(organization.id, reducer.id, identities)
+ # Temporary: credits come from customer meters until credits are reducers.
+ # Credits reset on renewal before the billed usage gets sealed, so balances
</file context>
…r-bucket-event # Conflicts: # server/tests/reducer_bucket/test_service.py
Summary
Related Issue: #
What
Why
How
Checklist
uv run task lint && uv run task lint_types)