Skip to content

Fix #499: add use_namespace_prefix_keys option to enable message keys that have unhashed namespace prefix#842

Merged
LincolnPuzey merged 5 commits into
Bogdanp:masterfrom
JoaoAlmeida20:result-message-namespace
Apr 3, 2026
Merged

Fix #499: add use_namespace_prefix_keys option to enable message keys that have unhashed namespace prefix#842
LincolnPuzey merged 5 commits into
Bogdanp:masterfrom
JoaoAlmeida20:result-message-namespace

Conversation

@JoaoAlmeida20
Copy link
Copy Markdown
Contributor

Addresses #499, based on #615 PR, which was closed for being a breaking change, making it necessary to guard it behind a flag or otherwise guaranteeing compatibility with old style keys, which didn't end up being addressed at the time. Here, the new behavior only happens if we set use_namespace_prefix_keys to True in the ResultsBackend instance.

I didn't start a discussion since the PR is based on an existing PR and the feedback it had already gotten, apologies if that was skipping a step.

@LincolnPuzey
Copy link
Copy Markdown
Collaborator

LincolnPuzey commented Mar 15, 2026

Hi @JoaoAlmeida20, skipping the conversation is ok since there is the existing issue/PR/feedback, I'll have a look, thanks

Comment thread dramatiq/results/backend.py
Comment thread dramatiq/results/backend.py Outdated
"actor_name": message.actor_name,
"message_id": message.message_id,
}
hashed_key = hashlib.md5(message_key.encode("utf-8")).hexdigest()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to still md5 the part after the namespace? #615 Didn't do that.

Feels like it would be nicer to not use any MD5? That way you have different useful prefixes to work with in the final key:

namespace:
namespace:queue:
namespace:queue:actor:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that does sound better. I considered it briefly, but I didn't notice the message_key went unhashed in #615 already. Changed it in de987eb

…none of the key components are md5 hashed, add use_namespace_prefix_keys to RedisBackend and MemcachedBackend inits
Copy link
Copy Markdown

@themavik themavik left a comment

Choose a reason for hiding this comment

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

Default-off use_namespace_prefix_keys keeps MD5 keys; StubBackend test proves readable keys when enabled. nit: prefixed keys join queue, actor, and id with colons, so queue or actor names containing colons break naive split-based tooling or scripts.

Copy link
Copy Markdown
Collaborator

@LincolnPuzey LincolnPuzey left a comment

Choose a reason for hiding this comment

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

Looks good @JoaoAlmeida20 , can you resolve the conflict? thanks

@LincolnPuzey LincolnPuzey linked an issue Apr 3, 2026 that may be closed by this pull request
7 tasks
@LincolnPuzey LincolnPuzey merged commit 0fe6c76 into Bogdanp:master Apr 3, 2026
15 checks passed
@LincolnPuzey LincolnPuzey added this to the v2.2.0 milestone Apr 3, 2026
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.

Namespacing not used for RedisBackend results storage

3 participants