fix: fail cleanly on templates with memberless grouped statements#553
Merged
Conversation
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>
Contributor
|
🎉 This PR is included in version 5.6.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
Opening
/publish?template=…with a template that types a statement asnt:GroupedStatementbut declares no group→membernt:hasStatementlinks (e.g. https://w3id.org/np/RAaL0nZfLxsGAbLUvSFSA7pNu7H0e46rl9egKphYCEELk, created via the template-editor meta-template) crashed the whole page with an opaque Wicket 500:Template.processNpTemplateiteratedgetStatementIris(groupIri), which isnullfor a memberless group → NPE inside theTemplateconstructor.TemplateData.getTemplatecaught it, logged only the bare message (no template id, no stack trace), and returnednull.PublishForm's target-namespace block dereferenced thatnull→ 500.Fix
MalformedTemplateException("Grouped statement has no member statements: …")instead of NPE-ing. Tolerating the group silently isn't an option:StatementItemalso assumes members exist, and rendering the statements ungrouped would drop the author's optional-group semantics..negative) error message instead of constructing aPublishFormthat is doomed to fail.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