Skip to content

fix: fail cleanly on templates with memberless grouped statements#553

Merged
tkuhn merged 1 commit into
masterfrom
fix/memberless-grouped-statement-crash
Jul 13, 2026
Merged

fix: fail cleanly on templates with memberless grouped statements#553
tkuhn merged 1 commit into
masterfrom
fix/memberless-grouped-statement-crash

Conversation

@tkuhn

@tkuhn tkuhn commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Problem

Opening /publish?template=… with a template that types a statement as nt:GroupedStatement but declares no group→member nt:hasStatement links (e.g. https://w3id.org/np/RAaL0nZfLxsGAbLUvSFSA7pNu7H0e46rl9egKphYCEELk, created via the template-editor meta-template) crashed the whole page with an opaque Wicket 500:

  1. The redundant-group-link cleanup in Template.processNpTemplate iterated getStatementIris(groupIri), which is null for a memberless group → NPE inside the Template constructor.
  2. TemplateData.getTemplate caught it, logged only the bare message (no template id, no stack trace), and returned null.
  3. PublishForm's target-namespace block dereferenced that null → 500.

Fix

  • Template: the cleanup loop now throws MalformedTemplateException("Grouped statement has no member statements: …") instead of NPE-ing. Tolerating the group silently isn't an option: StatementItem also assumes members exist, and rendering the statements ungrouped would drop the author's optional-group semantics.
  • TemplateData: log the template id and full stack trace on load failure, so the next case is diagnosable from the log.
  • PublishPage: when the template can't be loaded, show a red (.negative) error message instead of constructing a PublishForm that is doomed to fail.
  • PublishForm: null-guard the template lookup in the target-namespace block.

The affected template itself needs to be republished with the group-membership links filled in; with this fix nanodash reports the problem instead of crashing.

🤖 Generated with Claude Code

A template typing a statement as nt:GroupedStatement without declaring
its members via nt:hasStatement crashed the whole publish page: the
redundant-group-link cleanup in Template.processNpTemplate NPE'd on the
null member list, TemplateData.getTemplate swallowed the exception and
returned null, and PublishForm then dereferenced that null.

- Template: throw MalformedTemplateException with the group IRI instead
  of the NPE (memberless groups can't be rendered anyway)
- TemplateData: log the template id and full stack trace on load failure
- PublishPage: show a red error message instead of constructing a
  PublishForm doomed to fail when the template can't be loaded
- PublishForm: null-guard the template lookup in the target-namespace
  block

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tkuhn tkuhn merged commit 43a9f68 into master Jul 13, 2026
4 checks passed
@tkuhn tkuhn deleted the fix/memberless-grouped-statement-crash branch July 13, 2026 14:25
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.6.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