Skip to content

hotfix(transcribe): add missing import random (#6022)#6035

Merged
beastoin merged 1 commit into
mainfrom
fix/pusher-missing-random-import-6022
Mar 25, 2026
Merged

hotfix(transcribe): add missing import random (#6022)#6035
beastoin merged 1 commit into
mainfrom
fix/pusher-missing-random-import-6022

Conversation

@beastoin
Copy link
Copy Markdown
Collaborator

Fixes NameError in production: name 'random' is not defined at transcribe.py:1514.

The _pusher_reconnect_loop (from PR #6030) uses random.random() for backoff jitter but the import random statement was missing. This causes the reconnect loop to crash immediately, preventing circuit breaker recovery.

One-line fix: add import random to the stdlib imports.


by AI for @beastoin

The _pusher_reconnect_loop uses random.random() for backoff jitter but
import random was missing, causing NameError in production.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@beastoin beastoin merged commit 5c5fe40 into main Mar 25, 2026
2 checks passed
@beastoin beastoin deleted the fix/pusher-missing-random-import-6022 branch March 25, 2026 09:07
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 25, 2026

Greptile Summary

This is a one-line hotfix that adds the missing import random statement to backend/routers/transcribe.py, resolving a production NameError: name 'random' is not defined introduced by PR #6030's _pusher_reconnect_loop implementation.

  • The random module is used at line 1515 for exponential-backoff jitter: delay *= 0.75 + random.random() * 0.5.
  • Without this import, every reconnect attempt crashed immediately, preventing the circuit breaker from ever recovering a Pusher connection.
  • The import is inserted in the correct alphabetical position among the stdlib imports (between os and struct), consistent with the file's existing style.

Confidence Score: 5/5

  • Safe to merge — minimal one-line stdlib import fix with no side effects.
  • The change adds a single, standard-library import that is unambiguously required by existing code. There is no risk of regression and it directly unblocks a broken production code path.
  • No files require special attention.

Important Files Changed

Filename Overview
backend/routers/transcribe.py Adds the missing import random stdlib import; fixes the production NameError at line 1515 where random.random() is used for jitter in _pusher_reconnect_loop.

Sequence Diagram

sequenceDiagram
    participant RL as _pusher_reconnect_loop
    participant R as random (stdlib)
    participant P as Pusher Client

    RL->>RL: connection failure detected
    RL->>RL: compute base delay (exponential backoff)
    RL->>R: random.random() — jitter ±25%
    R-->>RL: float in [0.0, 1.0)
    RL->>RL: delay *= 0.75 + jitter * 0.5
    RL->>RL: asyncio.sleep(delay)
    RL->>P: attempt reconnect
    P-->>RL: success / failure
Loading

Reviews (1): Last reviewed commit: "fix(transcribe): add missing import rand..." | Re-trigger Greptile

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