Skip to content

Do not fail schema compilation on a superfluous slice - #694

Merged
alexzautke merged 1 commit into
developfrom
claude/fix-662-superfluous-slice
Oct 4, 2026
Merged

alexzautke merged 1 commit into
developfrom
claude/fix-662-superfluous-slice

Conversation

@claude

@claude claude Bot commented Sep 30, 2026

Copy link
Copy Markdown

Requested by Ewout Kramer · Slack thread

Description

SchemaBuilder threw an IncorrectElementDefinitionException when the discriminator condition of a slice always succeeds (or always fails), which stopped the whole profile from being compiled. Such a slice is superfluous but not wrong (see the discussion in the issue), and the SliceValidator handles a fixed-result condition correctly as it is, so the exception is removed.

The issue asks for a warning instead of silence; the SchemaBuilder has no warning mechanism yet (see #430), so for now the slice is simply compiled without complaint.

Related issues

Closes #662

Testing

  • New SuperfluousSliceTests (R4 compilation tests): a profile slicing Patient.name with a profile discriminator on $this (no profiles on the element, so the condition always succeeds). Fails before the change with the error from the issue ("...cannot be used as a slicing discriminator"), 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 without warnings or errors.
  • Not verified against the original diagnosticReport-eu-eps profile from the issue (attachment not reachable from this environment).

🤖 Generated with Claude Code

https://claude.ai/code/session_01J2SNRG6mrRVURXPQCPiau5


Generated by Claude Code

A slice whose discriminator(s) always succeed (or always fail) is superfluous,
but not wrong: the SliceValidator handles such a condition correctly. Throwing
an IncorrectElementDefinitionException here prevented the whole profile from
being compiled. Drop the exception (and the message's missing space).

Adds a test with a profile discriminator on an element without profiles.

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 October 1, 2026 00:13
Copilot AI balanced review requested due to automatic review settings October 1, 2026 00:13

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 is consistent with SliceValidator semantics and has regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Removes schema compilation failure for superfluous slices with fixed discriminator results.

Changes:

  • Allows fixed-result slice conditions to compile.
  • Adds an R4 regression test for an always-successful discriminator.
File Description
SchemaBuilder.cs Stops rejecting fixed-result slice conditions.
SuperfluousSliceTests.cs Verifies successful compilation and validation.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@alexzautke
alexzautke merged commit fb9499a into develop Oct 4, 2026
4 checks passed
@alexzautke
alexzautke deleted the claude/fix-662-superfluous-slice branch October 4, 2026 13:39
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.

Superfluous slice should not result in an error

4 participants