Repository navigation
fix(publish): say which template could not be loaded instead of failing - #926
Merged
Merged
Conversation
A publish form is made of several templates. When one of the built-in ones (default provenance, creator, license, ...) could not be fetched, the form went on with a context that had no template and the request ended in a NullPointerException. It now fails with TemplateUnavailableException, and the publish page, the connector publish page and the thread response form show a notice naming the template in its place. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 5.23.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
A publish form is built from several templates: the assertion template plus provenance and publication info templates, some of them built in (default provenance, creator, license, ...).
TemplateData.getTemplatereturns null for a template that cannot be fetched. Only the assertion template was checked for that; for any other one the form carried on and the request ended in aNullPointerExceptioninTemplateContext.initStatements— a 500 for the user whenever the registry hiccups.This is also what failed
DateTimeKeepValueTestin the first CI run of #924.Change
PublishFormthrows a newTemplateUnavailableException(kind of template + ID) as soon as a context has no template.PublishPage,GenPublishPageand the thread response form (ThreadNodePanel) catch it and show a notice in place of the form: "Error: The provenance template of this form could not be loaded: . It might be invalid or temporarily unavailable." The ID is escaped.Not changed
Tests that render a publish form still fetch the built-in templates from the live registry, so they can still fail when it is unreachable — now with a
TemplateUnavailableExceptionnaming the template instead of aNullPointerException.Testing
PublishFormTemplateErrorTest(the exception, and the notice with an ID that needs escaping).mvn test: 1892 tests, one unrelated error in the full run (NanodashPageMetadataTest.aPageWithoutASubjectAsksNotToBeIndexed, a view that did not load); that class passes when run again on its own.NANOPUB_REGISTRY_INSTANCESpointing at a proxy to the live registry that answers 503 for the default provenance template./publish?template=…returned 200 with the notice instead of a 500; with the proxy unblocked, the same URL showed the form again.🤖 Generated with Claude Code