envoy icon indicating copy to clipboard operation
envoy copied to clipboard

redis key_formatter should handle cases where client keys contain hash tag

Open weitsung-lin opened this issue 2 years ago • 6 comments

Title: redis key_formatter should handle cases where client keys contain hash tag

Description: Redis supports hash tag feature which can be used to to take a curly braces wrapped substring for key hash. Consider a scenario where user specify a key_formatter that uses hash tag, e.g. prefix-{%KEY%}, and the client key contains hash tag as well, e.g. foo-{bar}. The formatted key becomes prefix-{foo-{bar}} and foo-{bar will be used for hash instead ofbar intended by client. The proposed change is to add an option for key_formatter to prefer client key's hash tag if present. If the feature is enabled and the first pair of curly braces in key_formatter wraps %KEY% which also contains hash tag, the key_formatter will be stripped off of the pair of curly braces. In the above example, the formatted key becomes prefix-foo-{bar}.

[optional Relevant Links:] redis hash tag

weitsung-lin avatar Nov 16 '23 00:11 weitsung-lin

CC @ramaraochavali @deveshkandpal1224

weitsung-lin avatar Nov 16 '23 00:11 weitsung-lin

@msukalski @henryyyang @mattklein123 @weisisea

htuch avatar Nov 16 '23 04:11 htuch

Is there a reason not to do it by default? Do we need a config? If you are worried about BC, may be a runtime flag is fine - not sure it is worth any api change?

ramaraochavali avatar Nov 16 '23 09:11 ramaraochavali

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 16 '23 12:12 github-actions[bot]

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

github-actions[bot] avatar Dec 23 '23 16:12 github-actions[bot]

I feel like this should be done in an API field validation rather than trying to handle at the formatter implementation. like for example reject if a curly bracket is present in the key_formatter string in the first place, or at least print a warning like that would break the intended hash tag use by the client.

mathetake avatar Jun 28 '24 16:06 mathetake