Repository navigation
Skip meta.profile entries without a string value when picking profiles - #712
Merged
andrzejskowronski merged 1 commit intoOct 20, 2026
Merged
Conversation
GetMetaProfileSchemas cast every meta.profile value to a string and built a Canonical from it. An entry without a value (valid FHIR when it only carries an extension) threw ArgumentNullException in every parse mode, and a non-string JSON value kept by a lenient parse threw InvalidCastException. Neither names a profile, so both are now skipped. Fixes #710 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PMryuSqWt3gpT2vJdDfXh8
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow filtering change preserves valid profile behavior and has targeted regression coverage, with no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes profile selection to ignore meta.profile entries without string values while preserving valid profile URLs.
Changes:
- Filters out null and non-string values before constructing canonicals.
- Adds regression tests for profile selection and extension-only entries across FHIR versions.
| File | Description |
|---|---|
| test/Firely.Fhir.Validation.Tests/Impl/ResourceSchemaTests.cs | Tests skipping null and numeric profile values. |
| test/Firely.Fhir.Validation.Compilation.Tests.Shared/ResourceSchemaValidationTests.cs | Tests validation of extension-only profile entries. |
| src/Firely.Fhir.Validation/Impl/ResourceSchema.cs | Limits profile selection to string values. |
Review effort: Balanced
andrzejskowronski
approved these changes
Oct 20, 2026
andrzejskowronski
deleted the
claude/fix-710-meta-profile-without-value
branch
October 20, 2026 09:45
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.
Description
ResourceSchema.GetMetaProfileSchemasbuilt aCanonicalfrom everymeta.profilevalue with(string)pn.GetValue()!. This method runs for every resource, so validation threw instead of returning an outcome when:"_profile": [{"extension": [...]}]. It threwArgumentNullExceptionin every parse mode, includingStrict.SyntaxOnly,Recoverable) kept a non-string JSON value, e.g."profile": [5]. It threwInvalidCastException.Neither case names a profile, so only string values are taken now (
.OfType<string>()). Nothing changes for valid profile URLs.Not covered here:
"profile": [5]still throws, but later, inCanonicalValidator. ItsCanonical.Valuegetter throws on a non-string raw value. That is the wrong-typed-value problem from Investigate and fix our fatal errors. #559/Investigate and fix errors in the model that lead to fatals on the validator #561, which also makes theprimitive-badtest case expect a-1crash.ExtensionContextValidatoraccepts aDATATYPEcontext only when it is"Any"(ExtensionContextValidator.cs:107), not"*". So STU3 extensions with context datatype*, such as data-absent-reason, are reported as "used outside of appropriate contexts" wherever they appear. The new shared test uses iso21090-nullFlavor on STU3 to work around this.Related issues
Closes #710
Testing
ResourceSchemaTests.MetaProfileWithoutStringValueIsSkipped: an entry with only an extension, and a number value, parsed inSyntaxOnlymode. Only the string profile is returned.ResourceSchemaValidationTests.ValidatesMetaProfileWithoutValue(shared, so it runs on STU3/R4/R4B/R5): a Patient whose onlymeta.profileentry carries an extension validates without issues.ArgumentNullException/InvalidCastException) and pass with it.dotnet build Firely.Validator.API.slnx -c Releaseand all test projects pass:Firely.Fhir.Validation.Tests335, Compilation R4 505, R4B 136, R5 331, STU3 177 (3 skipped per Compilation project, as ondevelop). No schema snapshot changes.Generated by Claude Code