Skip to content

Ignore targetProfile on a non-reference type when compiling - #695

Merged
ewoutkramer merged 1 commit into
developfrom
claude/fix-423-ignore-targetprofile-non-reference
Sep 30, 2026
Merged

ewoutkramer merged 1 commit into
developfrom
claude/fix-423-ignore-targetprofile-non-reference

Conversation

@claude

@claude claude Bot commented Sep 30, 2026

Copy link
Copy Markdown

Requested by Ewout Kramer · Slack thread

Description

TypeReferenceBuilder threw an IncorrectElementDefinitionException when a type reference carried targetProfiles but the type is not a Reference/canonical. That stopped the whole StructureDefinition from compiling (the MedMij case in the issue). A targetProfile on such a type is meaningless, so it is now ignored.

The issue notes a warning would be ideal, but the SchemaBuilder has no warning mechanism yet (see #430), so it is ignored silently for now.

Related issues

Closes #423

Testing

  • New TargetProfileOnNonReferenceTests (R4 compilation tests): a profile with a targetProfile on Patient.birthDate (type date) 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 uninitialized FhirTestCases git submodule (RoundTripTest, RunFirelySdkTests, RunSingleTest); these fail identically without this change.
  • STU3/R4B/R5 validator projects build cleanly (shared code).

🤖 Generated with Claude Code

https://claude.ai/code/session_01J2SNRG6mrRVURXPQCPiau5


Generated by Claude Code

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
ewoutkramer marked this pull request as ready for review September 30, 2026 21:59
Copilot AI balanced review requested due to automatic review settings September 30, 2026 21:59
@ewoutkramer
ewoutkramer merged commit 99b519e into develop Sep 30, 2026
3 checks passed
@ewoutkramer
ewoutkramer deleted the claude/fix-423-ignore-targetprofile-non-reference branch September 30, 2026 21:59

Copilot AI 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.

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 targetProfile metadata 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.

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.

Consider ignoring targetProfile on a non-reference type when compiling

3 participants