Repository navigation
fix(backend): expose with_rate_limit on the task-sharing endpoints stub - #12057
Merged
Git-on-my-level merged 1 commit intoAug 22, 2026
Merged
Git-on-my-level merged 1 commit into
Git-on-my-level merged 1 commit into
Conversation
tests/unit/test_task_sharing.py fails at collection on main, which errors the whole Backend unit suite: ERROR tests/unit/test_task_sharing.py - AttributeError: module 'utils.other.endpoints' has no attribute 'with_rate_limit' The file stubs utils.other.endpoints with only get_current_user_uid, but routers/action_items.py:362 now resolves the wrapper at module level: Depends(auth.with_rate_limit(auth.get_current_user_uid, "action_items:list")) so importing the router under the stub raises before any test runs. The stub predates that wrapper; nothing about the sharing behavior under test changed. The stub passes the auth dependency straight through. The real with_rate_limit only wraps it with a Redis per-UID check, which these tests neither exercise nor have a Redis for -- database.redis_db.r is itself a MagicMock a few lines above. Verified both directions on a pristine checkout of main: before: no tests collected, 1 error in 0.35s after: 30 passed black --line-length 120 --skip-string-normalization clean.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
abunet
added a commit
to abunet/omi
that referenced
this pull request
Aug 22, 2026
…dy fixed one of our PRs
Four conflicts, all real this time (no generated-file counters).
backend/database/action_items.py both sides had independently replaced the streaming counts with
count() aggregations. Upstream's version wins: it also handles
legacy rows where `deleted` is ABSENT, which ours did not — it
reads that small subset once and subtracts, where ours filtered
`deleted == True` and so would have missed them.
backend/tests/unit/test_task_sharing.py upstream fixed this themselves (BasedHardware#12057, one day after we
proposed the same fix) with the same diagnosis in the same terms.
Theirs is canonical now; ours was a proposal. Taken as-is.
backend/tests/unit/test_desktop_migration.py their test for their rewritten counting.
app/pubspec.yaml union: their `sign_in_with_apple` bump plus our two additive OIDC
dependencies (ADR-0038).
**A mistake worth recording, because it nearly shipped.** I first resolved action_items.py with
`git checkout --theirs`, which replaces the WHOLE FILE, not the conflicting hunks — silently discarding
our `AlreadyExists` import and its handler from the Mongo unique-index dedup (ADR-0085), which had
auto-merged cleanly nowhere near the conflict. Caught by grepping the file for our own deltas after
resolving rather than by any test: the dedup path has contract cover, but that suite would only have
gone red later, on a branch where the loss looked like part of the merge. Both files were re-resolved
hunk by hunk.
Post-merge audit (ADR-0029/0030): one finding, from the guards.
PROMETHEUS_SIDECAR_PORT a new upstream runtime variable. Written off rather than declared, with the
reason: unset, `utils/metrics.py:445` returns immediately and nothing starts;
set, it opens a SECOND http server on 127.0.0.1 for a Cloud Run sidecar to
scrape. On-prem there is no sidecar and /metrics is already reachable on the
backend's own surface (ADR-0068), so a loopback duplicate would serve nobody.
The note points at the metrics-consumer work (L43), where it becomes relevant
if the collector ever runs beside the backend instead of scraping it.
One observation not acted on, to keep the merge a merge: upstream's `daily_completed` and `daily_total`
come from two separate aggregations, so a concurrent write between them can leave completed above total.
Ours capped the pair; theirs does not. Product logic, theirs to decide — worth a PR, not a local
divergence.
Verification
guards 9/9 exit 0 — the env-parity guard is what surfaced the finding above
contract lane 55 files, 1083 passed, 78 skipped (live-tier only), 0 failed
full sweep 1027 files in 3m19s, FAIL set identical to the pre-merge baseline
black 24.4.2 clean on all three resolved backend files
3 tasks done
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
tests/unit/test_task_sharing.pyfails at collection onmain, which errors the wholeBackend unit suitejob:Because it is a collection error rather than a test failure, the job exits 1 before running, so every backend PR inherits a red
Backend unit suitethrough its merge ref.Cause
The file stubs
utils.other.endpointswith a single attribute:routers/action_items.py:362now resolves the rate-limit wrapper at module level, so it is evaluated at import:Importing the router under that stub raises before any test runs. The stub predates the wrapper; nothing about the sharing behavior under test changed.
The fix
One stub entry that passes the auth dependency straight through. The real
with_rate_limitonly wraps it with a Redis per-UID check — which these tests neither exercise nor have a Redis for, sincedatabase.redis_db.ris itself aMagicMocka few lines above in the same file.Verification
Both directions, on a pristine checkout of
main(not on a feature branch):black --line-length 120 --skip-string-normalization --checkreports the file unchanged.Notes
I hit this because it reddens
Backend unit suiteon my own PR #11452, but the failure is not from that diff —main's own run at08-22T14:42(fix(backend): cap GET /v1/action-items at 12) shows the identical error. This is the same shape as #12035 earlier today: a small test-side fix unblocking a lane for everyone, and I am equally happy for someone to land an equivalent fix directly instead of merging this.Product invariants affected
none
Failure-Class: none