Skip to content

Don't strip invalid characters from ImplementationGuide name (#1271) - #1639

Merged
cmoesel merged 1 commit into
FHIR:masterfrom
cpruijsen:fix/issue-1271
Sep 17, 2026
Merged

cmoesel merged 1 commit into
FHIR:masterfrom
cpruijsen:fix/issue-1271

Conversation

@cpruijsen

Copy link
Copy Markdown
Contributor

Description:

SUSHI was quietly removing non-alphanumeric characters from ImplementationGuide.name (except _) and not capitalizing the first letter, so the result could still violate FHIR name.matches('[A-Z]([A-Za-z0-9_]){0,254}').

initIG now assigns config.name as authored. If the name is present and does not match that constraint, SUSHI logs a warning that quotes the constraint and points at the "name" property in sushi-config.yaml. It does not auto-capitalize and does not keep stripping.

This matches how Profile / ValueSet / CodeSystem names are already handled (HasName.setName): leave the value, warn, let the author fix it.

What I chose and the alternative: leave the name as authored and warn. The alternative is to keep stripping (and maybe capitalize the first letter) and also warn. I chose leave-and-warn because that is what #1271 asks for, and because silent cleanup was the confusing part, including cases like Minimal IG that used to become a FHIR-valid MinimalIG with no log. Happy to switch if maintainers would rather share nameRegex from mixins.ts, keep a sanitized export plus a warn, or treat this as an error instead of a warning.

Testing Instructions:

  • npm test -- test/ig/IGExporter.test.ts
  • In a project whose sushi-config.yaml has name: Minimal IG, confirm the generated ImplementationGuide-*.json keeps name: "Minimal IG" and the build log warns with [A-Z]([A-Za-z0-9_]){0,254}.
  • With name: MinimalIG, confirm the name is unchanged and that constraint warning is not emitted.

Note: authors who previously relied on SUSHI stripping spaces or hyphens will now export the invalid name and see a warning (and IG Publisher may reject it) until they fix sushi-config.yaml. Use title for the human label; name is the machine identifier.

Related Issue:

Fixes #1271

Leave sushi-config.yaml name as authored and warn when it violates the FHIR name constraint, instead of silently removing non-alphanumerics.

@cmoesel cmoesel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution, @cpruijsen. This looks great. The warning message is helpful too. Approved!

Thanks again!

@cmoesel
cmoesel merged commit eb3beb9 into FHIR:master Sep 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't try to clean up IG name

2 participants