Skip to content

RabbitMQ address configuration properties don't support percent-encoded values in the URI #52623

Closed

Description

@manuel-umu

A common way to configure RabbitMQ is to take the URI provided by the platform or a secret store and pass it straight through, for example SPRING_RABBITMQ_ADDRESSES=${RABBITMQ_URL}. That works as long as the URI contains no percent-encoded characters. When it does, Boot uses the encoded values as they are, while RabbitMQ decodes them as the AMQP URI spec describes:

Address Spring Boot RabbitMQ
amqp://user:secret@localhost:5672/%2F vhost %2F vhost /
amqp://user:p%40ss@localhost:5672/vh password p%40ss password p@ss
amqp://us%3Aer:secret@localhost:5672/my%2Fvhost user us%3Aer, vhost my%2Fvhost user us:er, vhost my/vhost

So a URI that the RabbitMQ client accepts fails to authenticate, or connects to the wrong virtual host, with Boot. For example, if a generated password contains a symbol like @ or /, or if the default / virtual host is written as %2F.

Setting username, password and virtual-host separately works around it, but that means splitting a URI that should work as is.

I checked this on 4.1.2 using RabbitProperties.determinePassword() and determineVirtualHost(), which feed the auto-configured connection details. From reading the code, the new AMQP 1.0 support in 4.2 (PropertiesAmqpRabbitConnectionDetails) parses spring.amqp.rabbitmq.address the same way.

I found the issue #3328 where it is discussed about reworking how addresses are handled, but this doesn't need that. Decoding the values after they've been parsed should be enough, and it only changes anything for addresses that contain %. Happy to send a PR if that sounds reasonable.

Activity

  1. added
    status: waiting-for-triage
    on Nov 4, 2026
  2. self-assigned this
    on Nov 5, 2026
  3. added
    type: bug
    and removed
    status: waiting-for-triage
    on Nov 5, 2026
  4. added this to the 4.0.x milestone on Nov 5, 2026
  5. changed the title [-]spring.rabbitmq.addresses doesn't decode percent-encoded credentials or virtual host[/-] [+]RabbitMQ address configuration properties don't support percent-encoded values[/+] on Nov 6, 2026
  6. changed the title [-]RabbitMQ address configuration properties don't support percent-encoded values[/-] [+]RabbitMQ address configuration properties don't support percent-encoded values in the URI[/+] on Nov 6, 2026
  7. modified the milestones: 4.0.x, 4.0.10 on Nov 6, 2026
  8. challa commented on Nov 6, 2026

    @challa
    Contributor

    For addresses with an explicit port, RabbitUri now decodes the username, password and virtual host with URLDecoder. That decoder handles HTML form data and turns + into a space. A literal + is valid in those parts of an AMQP URI, and RabbitMQ’s ConnectionFactory.setUri preserves it.

    With spring.rabbitmq.addresses=amqp://app:[email protected]:5672/orders, Boot 4.0.9, 4.1.2 and 4.2.0-RC2 use pa+ss. The 4.0.10-SNAPSHOT, 4.1.3-SNAPSHOT and 4.2.0-SNAPSHOT builds tested on November 6 use pa ss.

    RabbitProperties properties = new RabbitProperties();
    properties.setAddresses(List.of("amqp://app:[email protected]:5672/orders"));
    System.out.println(properties.determinePassword()); // 4.0.9: pa+ss, 4.0.10-SNAPSHOT: pa ss

    Against a local AMQP test broker configured with pa+ss, the @RabbitListener application started on 4.0.9 and failed authentication on 4.0.10-SNAPSHOT:

    Caused by: org.springframework.amqp.rabbit.listener.exception.FatalListenerStartupException: Authentication failure
    

    Using StringUtils.uriDecode preserves literal + and still decodes percent escapes, as in #50650. The second copy of RabbitUri on main, in spring-boot-amqp-rabbitmq for spring.amqp.rabbitmq.address, has the same behavior. I have a local patch and a regression test based on 4.0.x and can open a PR if that’s useful.

    I used an AI coding assistant for parts of the analysis. I reviewed and verified it myself.

  9. philwebb commented on Nov 6, 2026

    @philwebb
    Member

    Thanks @challa, good spot. Hopefully fixed in cef5af9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions