Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion flower/api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ async def get(self):
app = self.application

http_api = None
if app.transport == 'amqp' and app.options.broker_api:
if app.transport in ('amqp', 'amqps') and app.options.broker_api:
http_api = app.options.broker_api

broker = Broker(app.capp.connection().as_uri(include_password=True),
Expand Down
6 changes: 4 additions & 2 deletions flower/utils/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
class BrokerBase:
def __init__(self, broker_url, *_, **__):
purl = urlparse(broker_url)
self.scheme = purl.scheme
self.host = purl.hostname
self.port = purl.port
self.vhost = purl.path[1:]
Expand All @@ -40,13 +41,14 @@ def __init__(self, broker_url, http_api, io_loop=None, **__):
self.io_loop = io_loop or ioloop.IOLoop.instance()

self.host = self.host or 'localhost'
self.port = self.port or 15672
self.port = self.port or (15671 if self.scheme == 'amqps' else 15672)
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The default port logic for amqps (15671) differs from amqp (15672), but the existing test in tests/unit/utils/test_broker.py at line 35-42 (test_url_defaults_rabbitmq) expects both amqp:// and amqps:// to use port 15672. This test will fail with these changes and should be updated to verify that amqps:// defaults to port 15671 while amqp:// defaults to 15672.

Copilot uses AI. Check for mistakes.
self.vhost = quote(self.vhost, '') or '/' if self.vhost != '/' else self.vhost
self.username = self.username or 'guest'
self.password = self.password or 'guest'

if not http_api:
http_api = f"http://{self.username}:{self.password}@{self.host}:{self.port}/api/{self.vhost}"
http_scheme = 'https' if self.scheme == 'amqps' else 'http'
http_api = f"{http_scheme}://{self.username}:{self.password}@{self.host}:{self.port}/api/{self.vhost}"
Comment on lines +50 to +51
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The new logic for determining the http_scheme (https for amqps, http for amqp) lacks test coverage. Consider adding tests that verify the generated http_api URL uses the correct scheme: https://... for amqps:// broker URLs and http://... for amqp:// broker URLs.

Copilot uses AI. Check for mistakes.

try:
self.validate_http_api(http_api)
Expand Down
2 changes: 1 addition & 1 deletion flower/views/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async def get(self):
app = self.application

http_api = None
if app.transport == 'amqp' and app.options.broker_api:
if app.transport in ('amqp', 'amqps') and app.options.broker_api:
http_api = app.options.broker_api

try:
Expand Down
Loading