Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Webhook Custom HTTP Method + Basic Auth Support #4124
Webhook Custom HTTP Method + Basic Auth Support #4124
Changes from all commits
6f03025
5071e1c
fbb3fd2
52b01fe
cc0310c
6e9f74e
2b74b6f
0a0b09b
9973793
d66106d
6ef235d
04404c9
37e73ac
7580491
1fe18dc
f7502ee
97f8410
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Due to this change here[1] this is not necessary anymore . We know it will only be
PUT
orPOST
[1] https://github.com/ansible/awx/pull/4124/files#diff-a81324c523b41de7296fdd5ff9063d10R4240
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.
I disagree; I'd prefer to program defensively here in case the code ever changes (perhaps in the future, the validation code in the serializer code stops working properly, or perhaps we add some additional ORM code elsewhere that sets the HTTP method without properly validating it).
This if statement doesn't cost much, and it's a nice final line of defense against an uncaught exception.
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.
Fair. The thing that bothers me a bit is the DRY principles not being followed here.
and
Could we have
['put', 'post']
set somewhere and have those statement becomes something likeif self.http_method.lower() not in SUPPORTED_HTTP_METHOD
like statement ?This approach - I think - would satisfy both point of views
Note: Error message should rely upon this new variables too
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.
I'm a big fan of DRY as long as the reuse actually saves you something 😄. This is a one line if statement that's succinct, easy to read, and not likely to change drastically in the future.
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.
I'm a bit late to this conversation, but I wanted to show why I left that code in the
webhook_backend.py
file. IF somehow there is a nonsense HTTP method that gets past the UI and the serializer validator (admittedly this is a very unlikely scenario), without that code this is the error that shows up in the UI:This doesn't really explain what exactly went wrong. The code that I left in
webhook_backend.py
causes this error message to show up instead, which explains what exactly the user can fix: