Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend-agent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@
debug = bool(os.getenv('DEBUG', False))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The debug flag conversion could be more explicit and safer. The current implementation may not handle string values like 'false' or '0' correctly.

debug = os.getenv('DEBUG', 'false').lower() in ('true', '1', 'yes', 'on')

This approach properly converts string environment variables to boolean values, handling common representations of false/true.

print(f'Loading backend version {__version__} on port {port}')
app.run(host='0.0.0.0', port=int(port), debug=debug)
Comment on lines 72 to 73
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider adding error handling for the port conversion and app startup. The current code could fail silently or with unclear errors.

try:
    port_num = int(port)
    print(f'Loading backend version {__version__} on port {port_num}')
    app.run(host='0.0.0.0', port=port_num, debug=debug)
except ValueError:
    print(f'Error: Invalid port number "{port}"')
    sys.exit(1)
except Exception as e:
    print(f'Error starting server: {e}')
    sys.exit(1)

This provides better error handling and user feedback when the application fails to start.


Check failure on line 74 in backend-agent/main.py

View workflow job for this annotation

GitHub Actions / Flake8

backend-agent/main.py#L74

Blank line at end of file (W391)