Skip to content

fix(publish): say which template could not be loaded instead of failing - #926

Merged
tkuhn merged 1 commit into
masterfrom
fix/publish-form-missing-template
Nov 15, 2026
Merged

tkuhn merged 1 commit into
masterfrom
fix/publish-form-missing-template

Conversation

@tkuhn

@tkuhn tkuhn commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

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.getTemplate returns 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 a NullPointerException in TemplateContext.initStatements — a 500 for the user whenever the registry hiccups.

This is also what failed DateTimeKeepValueTest in the first CI run of #924.

Change

  • PublishForm throws a new TemplateUnavailableException (kind of template + ID) as soon as a context has no template.
  • PublishPage, GenPublishPage and 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.
  • Nothing is cached for a template that failed to load, so the form is back on the next visit once the template can be fetched.

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 TemplateUnavailableException naming the template instead of a NullPointerException.

Testing

  • Two new tests in 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.
  • End to end: a local instance with NANOPUB_REGISTRY_INSTANCES pointing 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

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>
@tkuhn
tkuhn merged commit cd89c68 into master Nov 15, 2026
8 checks passed
@tkuhn
tkuhn deleted the fix/publish-form-missing-template branch November 15, 2026 15:06
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant