Repository navigation
Conversation
… CLOUDAMQP_URL values **What goes wrong.** On a docker-compose self-host, the API's AMQP connection to the bundled broker can fail on every attempt while everything else looks healthy. The browser and the bot still connect over MQTT, but: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What goes wrong. On a docker-compose self-host, the API's AMQP connection to the bundled broker can fail on every attempt while everything else looks healthy. The browser and the bot still connect over MQTT, but:
AutoSyncJobfails its 4 attempts and is dropped), so the bot keeps running the old sequences and farm events until someone syncs by hand;rabbit_workersretries forever);Device#tellmessages are lost.The only sign is a
Connecting to broker in 3 seconds (#<URI::InvalidURIError ...>)line repeating in therabbit_jobscontainer's log.There are two ways to get there:
ADMIN_PASSWORDcontains a character that is not allowed in the userinfo part of a URL, e.g.@,#,/,?,%,{,}or a space. example.env asks for "something SECURE", and password-manager passwords often contain these.WHERE_IS_CLOUDAMQP_URL=,CLOUDAMQP_URL=andRABBITMQ_URL=. Unlike the neighbouring lines, these carry no "delete this" note.Cause.
app/models/transport.rb:p@ssw0rd99orabc#def123give a URL thatURI.parse(and therefore Bunny) rejects.env_fileturnsRABBITMQ_URL=into an empty string.ENV.fetch("WHERE_IS_CLOUDAMQP_URL", ...)returns"",ENV[""]is nil, andENV["RABBITMQ_URL"]is"", which is truthy in Ruby. Soamqp_urlis""and Bunny raises "Connection URI must use amqp or amqps schema".MQTT logins are not affected because RabbitMQ checks them over HTTP against the plain password, so nothing in the UI shows the problem.
What this change does.
app/models/transport.rb:CLOUDAMQP_ENV_KEY,CLOUDAMQP_URLandRABBITMQ_URLuse.presence, so blank values fall through to the default.Transport.default_amqp_url, which escapes the password withURI.encode_www_form_component. amq-protocol unescapes the userinfo when it parses the URL, so Bunny receives the original password.Transport::Mgmt.username/.passworddecode the userinfo they read from the URL so the management API client gets the real credentials, and a blankRABBIT_MGMT_URLfalls back to the computed URL.example.env: comments out the three AMQP lines and says that self-hosters using the bundled broker should leave them that way.spec/lib/transport_spec.rb: blank URL variables give the defaultmqttURL,RABBITMQ_URLis used when set, and a password containing@ # / ? % { }and a space produces a URL that parses and decodes back to the original password.How this helps a server without the cloud: the default
amqp://admin:...@mqtt:5672path is exactly what a LAN-only docker-compose install uses, and with this change it works with passwords like the ones above and with example.env as shipped.Testing. I wasn't able to run
rspeclocally (no Ruby toolchain on the machine I used), so I'd appreciate CI confirmation. The existingtransport_mgmt_specexpectation (Transport::Mgmt.password == ADMIN_PASSWORD) should still hold, since decoding a password that needed no escaping returns it unchanged. I haven't tested against a real broker.🤖 Generated with Claude Code