Skip to content

fix(celery): percent-encode the broker credentials - #60

Merged
IamMuuo merged 1 commit into
stagingfrom
fix/celery-broker-url
Jul 27, 2026
Merged

fix(celery): percent-encode the broker credentials#60
IamMuuo merged 1 commit into
stagingfrom
fix/celery-broker-url

Conversation

@IamMuuo

@IamMuuo IamMuuo commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Interpolating the RabbitMQ password straight into an amqp URL breaks when it contains a '#', '?' or '/': those terminate the netloc, so the port parses as whatever trailed the last colon and the connection dies with "Port could not be cast to integer value". '@' and ':' survive naive interpolation, which is why this held up until a password happened to contain one of the other three. Encode user, password, and vhost instead.

The event_bus consumers were never exposed to this because pika takes credentials as separate parameters. Celery is the first thing here to parse them as a URL, so the fault only surfaced once a worker ran.

Also stop an unreachable broker from failing the write. Outside an atomic block Django runs an on_commit callback inline, so the enqueue happens inside the request and any broker fault reaches the client as a 500 on task creation. The record is already committed as pending and the periodic sweep re-queues it, so log the failure and carry on: syncing late is better than refusing to save.

Interpolating the RabbitMQ password straight into an amqp URL breaks
when it contains a '#', '?' or '/': those terminate the netloc, so the
port parses as whatever trailed the last colon and the connection dies
with "Port could not be cast to integer value". '@' and ':' survive
naive interpolation, which is why this held up until a password
happened to contain one of the other three. Encode user, password, and
vhost instead.

The event_bus consumers were never exposed to this because pika takes
credentials as separate parameters. Celery is the first thing here to
parse them as a URL, so the fault only surfaced once a worker ran.

Also stop an unreachable broker from failing the write. Outside an
atomic block Django runs an on_commit callback inline, so the enqueue
happens inside the request and any broker fault reaches the client as a
500 on task creation. The record is already committed as pending and
the periodic sweep re-queues it, so log the failure and carry on:
syncing late is better than refusing to save.
@gitguardian

gitguardian Bot commented Jul 27, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 8 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
35216851 Triggered Generic Password bba1c4b keep_up/test_broker_url.py View secret
35216848 Triggered Generic Password bba1c4b keep_up/test_broker_url.py View secret
35216850 Triggered Generic Password bba1c4b keep_up/test_broker_url.py View secret
35216848 Triggered Generic Password bba1c4b keep_up/test_broker_url.py View secret
35216851 Triggered Generic Password bba1c4b keep_up/test_broker_url.py View secret
35216850 Triggered Generic Password bba1c4b keep_up/test_broker_url.py View secret
35216849 Triggered Generic Password bba1c4b keep_up/test_broker_url.py View secret
35216849 Triggered Generic Password bba1c4b keep_up/test_broker_url.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e1d98585-e1c7-4dba-a147-003ce38d97cb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/celery-broker-url

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@IamMuuo
IamMuuo merged commit c297ab2 into staging Jul 27, 2026
3 checks passed
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