Skip to content

Ignore meta.profile entries without a string value - #711

Closed
claude[bot] wants to merge 1 commit into
developfrom
bugfix/710-meta-profile-without-string-value
Closed

claude[bot] wants to merge 1 commit into
developfrom
bugfix/710-meta-profile-without-string-value

Conversation

@claude

@claude claude Bot commented Oct 19, 2026

Copy link
Copy Markdown

Requested via Slack thread

Description

Before: Validating a resource whose meta.profile entry has no string value threw instead of returning an outcome. An entry without a value (valid FHIR when it carries an extension, e.g. "_profile": [{"extension": [{"url": ".../data-absent-reason", "valueCode": "unknown"}]}]) threw ArgumentNullException in every deserialization mode, and a non-string value kept by a lenient parse ("profile": [5]) threw InvalidCastException.

After: Such entries are skipped when collecting the meta profiles, so they no longer throw at this point and the remaining entries are still used.

ResourceSchema.GetMetaProfileSchemas now only turns meta.profile entries with a string value into canonicals.

How: new Canonical((string)pn.GetValue()!) became pn.GetValue() filtered with OfType<string>() before creating the Canonical. An entry without a value names no profile to validate against; reporting an invalid value remains the job of the element's own validators.

Note: a non-string value like "profile": [5] still throws later, in CanonicalValidator (wrong-typed-value problem #559/#561). That is not covered here.

Related issues

Fixes #710

Testing

Added to ResourceSchemaTests: a value-less _profile entry (Strict, Recoverable and SyntaxOnly) is ignored while a valid entry is kept, a ResourceSchema validation of a resource with a value-less entry returns an outcome without throwing, and a non-string value (5) is ignored by GetMetaProfileSchemas. All five new cases fail without the fix; the full Firely.Fhir.Validation.Tests project passes (338 tests, net10.0).


Generated by Claude Code

ResourceSchema.GetMetaProfileSchemas cast every meta.profile value to
string, so an entry without a value (valid when it carries an extension)
threw ArgumentNullException, and a non-string value threw
InvalidCastException. Only entries with a string value name a profile.

Fixes #710

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rh3MA8tHrtq2e4fERVBj9i
@alexzautke

Copy link
Copy Markdown
Member

Duplicate of #712 712

@alexzautke alexzautke closed this Oct 19, 2026
@alexzautke
alexzautke deleted the bugfix/710-meta-profile-without-string-value branch October 19, 2026 19:16
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.

Validation throws when a meta.profile entry has no string value

2 participants