Prompt
Any data placed into connection URIs or transmitted over the network (e.g., JSON payloads/headers) must be encoded/serialized according to the protocol’s rules.
- URIs (userinfo: username/password): Percent-encode all characters in the username/password except RFC “unreserved” (
A-Z a-z 0-9 - . _ ~) and “sub-delims” (! $ & ' ( ) * + , ; =). - JSON/network metadata: Ensure values are JSON-serializable; don’t emit raw
UUIDobjects—convert to a string representation (commonly.hexorstr(uuid)).
Example:
from uuid import uuid4
from urllib.parse import quote
user = quote('alice+team', safe='')
password = quote('p@ss:word', safe='')
uri = f"amqp://{user}:{password}@host/vhost"
# For JSON/headers:
monitoring_id = uuid4().hex # not uuid4() directly
headers = {"monitoring_id": monitoring_id}