Repository navigation
Ignore targetProfile on a non-reference type when compiling - #695
Merged
ewoutkramer merged 1 commit intoSep 30, 2026
Merged
Conversation
A targetProfile on an element that is not a Reference/canonical is meaningless, but threw an IncorrectElementDefinitionException that stopped the whole profile from being compiled. Ignore it instead. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J2SNRG6mrRVURXPQCPiau5
ewoutkramer
approved these changes
Sep 30, 2026
ewoutkramer
marked this pull request as ready for review
September 30, 2026 21:59
ewoutkramer
deleted the
claude/fix-423-ignore-targetprofile-non-reference
branch
September 30, 2026 21:59
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused behavior change matches the issue and is covered by a regression test.
Review effort: Balanced
Findings: None
What changed in this PR
Updates schema compilation to tolerate meaningless targetProfile values on non-reference types.
Changes:
- Ignores invalid
targetProfilemetadata instead of aborting compilation. - Adds an R4 regression test covering successful compilation and validation.
| File | Description |
|---|---|
TypeReferenceBuilder.cs |
Removes the compilation exception for non-reference target profiles. |
TargetProfileOnNonReferenceTests.cs |
Verifies the invalid metadata is safely ignored. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
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.
Requested by Ewout Kramer · Slack thread
Description
TypeReferenceBuilderthrew anIncorrectElementDefinitionExceptionwhen a type reference carriedtargetProfiles but the type is not aReference/canonical. That stopped the whole StructureDefinition from compiling (the MedMij case in the issue). AtargetProfileon such a type is meaningless, so it is now ignored.The issue notes a warning would be ideal, but the
SchemaBuilderhas no warning mechanism yet (see #430), so it is ignored silently for now.Related issues
Closes #423
Testing
TargetProfileOnNonReferenceTests(R4 compilation tests): a profile with atargetProfileonPatient.birthDate(typedate) now compiles and validates. Fails before the change with "Encountered targetProfiles ... on an element that is not a reference type", passes after.Firely.Fhir.Validation.Compilation.R4.Tests: all pass except 3 tests that need the uninitializedFhirTestCasesgit submodule (RoundTripTest,RunFirelySdkTests,RunSingleTest); these fail identically without this change.🤖 Generated with Claude Code
https://claude.ai/code/session_01J2SNRG6mrRVURXPQCPiau5
Generated by Claude Code