Fix webhook template when validation errors occur #11421
Merged
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.
When creating a new webhook with bad data, the validation fails and Gitea tries to render the page with the "new webhook" templates - that fails most of the time, because none of the webhook post handler functions set the
HookType
template variable. Therefore, trying to add a new webhook with invalid data fails withemplate: repo/settings/webhook/new:10:9: executing "repo/settings/webhook/new" at <eq .HookType "gitea">: error calling eq: incompatible types for comparison
and the actual error message is never displayed.This PR fixes that by setting the
HookType
variable in all handler functions. (Maybe there's a better way to do this?).This hasn't been noticed until now because most of the webhooks either do frontend validation or no validation at all. I've noticed this with the matrix webhook which only does backend validation and therefore fails hard with the mentioned error message.