Skip to content

Exclude templates from isValid and isApproved publication checks#9422

Open
tylerjmchugh wants to merge 5 commits into
geonetwork:mainfrom
tylerjmchugh:publish-invalid-templates
Open

Exclude templates from isValid and isApproved publication checks#9422
tylerjmchugh wants to merge 5 commits into
geonetwork:mainfrom
tylerjmchugh:publish-invalid-templates

Conversation

@tylerjmchugh

@tylerjmchugh tylerjmchugh commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

When Allow publication of invalid metadata and Allow submission/approval of invalid metadata are both disabled, template records cannot be published or approved.
image

Templates are usually intentionally incomplete and are not expected to pass validation. However, the approval and publication checks currently apply the same validation requirements to templates as regular metadata records, causing the approval and publication to fail.

This PR aims to fix this issue by updating to skip the validation checks for templates.

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

@jodygarnett

Copy link
Copy Markdown
Contributor

Yes this totally makes sense as a bug! templates are by nature incomplete - let me review the PR.

The following settings control what metadata can be published when the metadata workflow is active. They are found under `Administration` --> `Settings` --> `Metadata Workflow`.

- **Allow publication of invalid metadata** When disabled, only metadata that passes all required XSD and schematron validation rules can be published. When enabled, metadata can be published regardless of its validation status. Templates are always exempt from this check, as they are typically incomplete by design.
- **Allow publication of non-approved metadata** When disabled, only metadata with an `Approved` workflow status can be published. When enabled, metadata can be published regardless of its workflow status. Templates are always exempt from this check, as they are not expected to go through the approval workflow.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unclear to me if tempaltes may be subject to an approval workflow? I could very much imagine a team wishing to approve a new workflow before sharing it for wider use?

@tylerjmchugh tylerjmchugh Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is agreed that templates should respect the Allow publication of non-approved metadata setting, maybe the Allow submission/approval of invalid metadata setting needs to also exclude templates instead. With that setting disabled, currently an invalid template could never be approved so again it would be unpublishable.

Updated the PR description accordingly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code so the "must be approved to publish" check is still respected. Instead I modified the "must be valid to approve" check to exclude templates.

So now an invalid template can be approved and then published.

@ianwallen ianwallen added the bug label Jul 15, 2026
@ianwallen ianwallen added this to the 4.4.13 milestone Jul 15, 2026
MetadataType metadataType = metadata.getDataInfo().getType();
if (metadataType == MetadataType.TEMPLATE
|| metadataType == MetadataType.SUB_TEMPLATE
|| metadataType == MetadataType.TEMPLATE_OF_SUB_TEMPLATE) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is starting to be a little silly, perhaps MetadataType should have a .isRequiresValidation() property :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest push

*/
@Test
public void publishInvalidTemplateSucceedsWhenPublishInvalidMdDisabled() throws Exception {
// Disable publishing of invalid metadata – the strict mode that triggered the bug.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the bug is addressed this comment will not make sense :P

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest push

@jodygarnett jodygarnett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have provided some small comments, but this change is fine as written.

Thanks for including test case which allows for prompt / efficient review.

@tylerjmchugh
tylerjmchugh force-pushed the publish-invalid-templates branch from 8595900 to acab98c Compare July 16, 2026 14:43
@tylerjmchugh

Copy link
Copy Markdown
Contributor Author

I have provided some small comments, but this change is fine as written.

Thanks for including test case which allows for prompt / efficient review.

Thank you for the review. I believe I have addressed all your comments

@tylerjmchugh
tylerjmchugh requested a review from jodygarnett July 16, 2026 14:46
@tylerjmchugh
tylerjmchugh force-pushed the publish-invalid-templates branch 2 times, most recently from 99dd750 to 94c8b15 Compare July 17, 2026 17:02
@tylerjmchugh
tylerjmchugh force-pushed the publish-invalid-templates branch from 94c8b15 to b15d7f5 Compare July 17, 2026 18:43
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.

3 participants