-
Notifications
You must be signed in to change notification settings - Fork 10
Validate channel names #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Alex-Izquierdo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are more use cases. You can look at https://github.com/ansible/eda-server/blob/main/src/aap_eda/utils/__init__.py#L40 for reference @AlanCoding
|
It would be easy to agree, but I'm trying to take an evidence-based approach. diff --git a/tests/integration/brokers/test_pg_notify.py b/tests/integration/brokers/test_pg_notify.py
index 8a052b6..9fc79e2 100644
--- a/tests/integration/brokers/test_pg_notify.py
+++ b/tests/integration/brokers/test_pg_notify.py
@@ -121,9 +121,11 @@ VALID_CHANNEL_NAMES = [
BAD_CHANNEL_NAMES = [
- '🔥' * 22, # under 64 but expanded unicode is over
+ 'a' + '🔥' * 22, # under 64 but expanded unicode is over
'a' * 64, # over the limit of 63
- 'a' * 120
+ 'a' * 120,
+ '',
+ '🔥aa' # First char must be alphabetical
]The blank string fails to send as expected. I don't know the specific exception, but an exception is raised so that all checks out. However, see the failure on In this test, it legitimately sent and then received a message over the If I put this in the valid channel list, the tests pass. I'll push a commit to try and make the sanity tests (testing psycopg) more clear. |
|
@AlanCoding I think it is because psycopg use quoted names by default (which supports unicode, for example). I just thought that we would want to be conservative and use unquoted ones, thinking on other potential clients or raw queries. But I don't have a strong opinion on this. |
|



Fixes #170
I originally made this because I anticipated raising an error if "-" was in the channel name.
But frustratingly, I couldn't make the code error in that case and came away with the conclusion that it is actually valid. Some things are invalid, but that's a more narrow case, still good to get ahead of it.