Fix #6165: Dynamically report backend_host in terminal logs#6191
Fix #6165: Dynamically report backend_host in terminal logs#6191pranavmanglik wants to merge 2 commits intoreflex-dev:mainfrom
Conversation
Greptile SummaryThis PR fixes issue #6165 by dynamically reporting the configured Key issues:
Confidence Score: 1/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Runner as App Runner
participant Exec as exec.notify_backend()
participant Config as get_config()
Runner->>Exec: notify_backend()
Exec->>Config: get_config()
Config-->>Exec: Config object (config)
Note over Exec: BUG: config() called<br/>with parentheses — TypeError!
Exec->>Exec: config().backend_host ❌
Exec->>Exec: config().backend_port ❌
Note over Exec: CORRECT: access attributes directly
Exec->>Exec: config.backend_host ✅
Exec->>Exec: config.backend_port ✅
Exec-->>Runner: console.print("Backend running at: http://{host}:{port}")
Last reviewed commit: "Fix #6165" |
| config = get_config() | ||
| console.print( | ||
| f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]" | ||
| f"Backend running at: [bold green]http://{config().backend_host}:{config().backend_port}[/bold green]" | ||
| ) |
There was a problem hiding this comment.
Config object called as a function — TypeError at runtime
get_config() returns a Config instance, not a callable. Assigning it to config and then invoking config() on line 164 (twice) will raise TypeError: 'Config' object is not callable every time notify_backend() is called.
The attributes should be accessed directly on the object returned by get_config():
| config = get_config() | |
| console.print( | |
| f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]" | |
| f"Backend running at: [bold green]http://{config().backend_host}:{config().backend_port}[/bold green]" | |
| ) | |
| config = get_config() | |
| console.print( | |
| f"Backend running at: [bold green]http://{config.backend_host}:{config.backend_port}[/bold green]" | |
| ) |
masenf
left a comment
There was a problem hiding this comment.
why did you make a new PR? the old one was fine and this one is broken
All Submissions:
Type of change
New Feature Submission:
Changes To Core Features:
Pull Request Details
Descriptive Title
fix: accurately report configured backend_host in terminal logsDescription of Changes
Currently, the
notify_backendfunction inreflex/utils/exec.pyhas the backend IP hardcoded as0.0.0.0. This leads to misleading terminal output when a user has explicitly configured a custombackend_host(e.g.,127.0.0.1for local-only development) in theirrxconfig.py.This PR modifies the notification logic to dynamically pull the
backend_hostfrom the Reflex configuration, ensuring the logs match the actual network binding. This improves developer clarity and assists in verifying security configurations.Testing performed:
backend_host="127.0.0.1"inrxconfig.py.http://127.0.0.1:8000instead of the hardcoded0.0.0.0.ruff) passes.Closing Issues
Closes #6165