Skip to content
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

Improve template error reporting #23396

Merged

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Mar 9, 2023

There are multiple duplicate reports of errors during template rendering due to broken custom templates.

Unfortunately the error returned here is somewhat difficult for users to understand and it doesn't return the context of the error.

This PR attempts to parse the error returned by the template renderer to add in some further context including the filename of the template AND the preceding lines within that template file.

Ref #23274

@zeripath zeripath added topic/deployment type/miscellaneous outdated/backport/v1.19 This PR should be backported to Gitea 1.19 labels Mar 9, 2023
@zeripath zeripath added this to the 1.20.0 milestone Mar 9, 2023
@zeripath
Copy link
Contributor Author

zeripath commented Mar 9, 2023

I've marked this as backport because it's precisely the kind of feature that is helpful to be backported.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 9, 2023
There are multiple duplicate reports of errors during template rendering
due to broken custom templates.

Unfortunately the error returned here is somewhat difficult for users to
understand and it doesn't return the context of the error.

This PR attempts to parse the error returned by the template renderer to
add in some further context including the filename of the template AND
the preceding lines within that template file.

Ref go-gitea#23274

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath force-pushed the add-context-to-template-render-error branch from 9e854ed to 3de0cdd Compare March 9, 2023 20:15
modules/context/context.go Outdated Show resolved Hide resolved
@lunny
Copy link
Member

lunny commented Mar 10, 2023

Could this display the root template name or the template dependency path when encountering a template error?

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor Author

Could this display the root template name or the template dependency path when encountering a template error?

I can't report the template dependency path but I've at least added the a message to say if the issue is a subtemplate.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 16, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 20, 2023
@lunny lunny added reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Mar 20, 2023
@yardenshoham yardenshoham added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Mar 20, 2023
@jolheiser
Copy link
Member

🎺 🤖

@jolheiser jolheiser merged commit 8f3aaef into go-gitea:main Mar 20, 2023
@jolheiser jolheiser removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 20, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Mar 20, 2023
There are multiple duplicate reports of errors during template rendering
due to broken custom templates.

Unfortunately the error returned here is somewhat difficult for users to
understand and it doesn't return the context of the error.

This PR attempts to parse the error returned by the template renderer to
add in some further context including the filename of the template AND
the preceding lines within that template file.

Ref go-gitea#23274

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Mar 20, 2023
@zeripath zeripath deleted the add-context-to-template-render-error branch March 20, 2023 21:19
jolheiser pushed a commit that referenced this pull request Mar 20, 2023
Backport #23396 by @zeripath

There are multiple duplicate reports of errors during template rendering
due to broken custom templates.

Unfortunately the error returned here is somewhat difficult for users to
understand and it doesn't return the context of the error.

This PR attempts to parse the error returned by the template renderer to
add in some further context including the filename of the template AND
the preceding lines within that template file.

Ref #23274

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 21, 2023
* upstream/main:
  Replace a few fontawesome icons with svg (go-gitea#23602)
  Fix pagination on `/notifications/watching` (go-gitea#23564)
  Fix `.locale.Tr` function not found in delete modal (go-gitea#23468)
  fix submodule is nil panic (go-gitea#23588)
  `Publish Review` buttons should indicate why they are disabled (go-gitea#23598)
  Improve template error reporting (go-gitea#23396)
  Polyfill the window.customElements (go-gitea#23592)
  Add CHANGELOG for 1.19.0 (go-gitea#23583)
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. outdated/backport/v1.19 This PR should be backported to Gitea 1.19 topic/deployment type/miscellaneous
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants