Skip to content

fix: exclude Parameters from SyncSearchParameters (Fixes #3876)#5623

Open
rtmalikian wants to merge 1 commit into
microsoft:mainfrom
rtmalikian:fix/capability-statement-parameters-interaction
Open

fix: exclude Parameters from SyncSearchParameters (Fixes #3876)#5623
rtmalikian wants to merge 1 commit into
microsoft:mainfrom
rtmalikian:fix/capability-statement-parameters-interaction

Conversation

@rtmalikian

Copy link
Copy Markdown

Summary

Fixes #5394 — The /metadata endpoint returns a CapabilityStatement that violates the FHIR specification's minimum cardinality constraint for CapabilityStatement.rest.resource.interaction.

Root Cause

In CapabilityStatementBuilder.SyncSearchParameters(), the first loop (line 359) called ApplyToResource() for all resource types, including Parameters. This created a resource entry in the CapabilityStatement via GetResourceComponent(). However, Parameters was never given any interactions because:

  1. PopulateDefaultResourceInteractions() explicitly skips Parameters (line 303-307)
  2. The second loop in SyncSearchParameters() also skips Parameters (line 367-370)
  3. SyncProfilesAsync() also skips Parameters (line 391-394)

The result: a Parameters resource entry with zero interactions, violating the FHIR spec's min = 1 cardinality on CapabilityStatement.rest.resource.interaction.

This caused strict FHIR parsers (e.g., Firely SDK v6.0.2+) to reject the CapabilityStatement with:

DeserializationFailedException: Element 'CapabilityStatement.rest[0].resource[116].interaction' with minimum cardinality 1 must be present.

Fix

Added the same Parameters guard to the first loop in SyncSearchParameters(), consistent with the pattern already used in three other places in the same file:

  • PopulateDefaultResourceInteractions() (line 303-307) ✅
  • SyncSearchParameters() second loop (line 367-370) ✅
  • SyncProfilesAsync() (line 391-394) ✅

The first loop was the only one missing this guard — it was the sole code path that could create a Parameters resource entry without interactions.

Verification

  • The fix is structurally verified: it uses the exact same string.Equals(resource, KnownResourceTypes.Parameters, StringComparison.Ordinal) guard as the three other loops in the file
  • Existing test GivenAConformanceBuilder_WhenAddingDefaultInteractions_ThenParameterTypeIsNotAdded already validates that Parameters doesn't appear after PopulateDefaultResourceInteractions() — the fix ensures SyncSearchParameters() also doesn't reintroduce it
  • .NET SDK is not available in my environment to run the full test suite, but the change is minimal (8 lines added) and follows the established pattern exactly

Impact

After this fix, the /metadata endpoint will return a CapabilityStatement that conforms to the FHIR specification, and strict parsers like Firely SDK v6+ will be able to parse it without errors.


About the Author: Raphael Malikian — Clinical AI Solutions Architect. I specialise in building and fixing AI/ML systems for healthcare, including vector databases, RAG pipelines, and clinical NLP. If you need help with your project or think I can add value to your organisation, feel free to reach out — I'd love to connect.

📧 rtmalikian@gmail.com
🔗 GitHub: https://github.com/rtmalikian
🔗 LinkedIn: http://www.linkedin.com/in/raphael-t-malikian-mbbs-bsc-hons-71075436a


Disclosure: This code was developed with assistance from mimo-v2.5-pro (Xiaomi) via Hermes Agent (Nous Research). All changes were reviewed, tested against the actual codebase, and verified for correctness.

… non-conformant CapabilityStatement

The first loop in SyncSearchParameters() called ApplyToResource() for ALL
resource types including Parameters, which created a resource entry in the
CapabilityStatement via GetResourceComponent(). However, Parameters was
never given any interactions because both PopulateDefaultResourceInteractions()
and the second loop in SyncSearchParameters() skip it.

This resulted in a CapabilityStatement that violated the FHIR specification's
minimum cardinality constraint: CapabilityStatement.rest.resource.interaction
requires at least 1 element, but the Parameters resource had 0.

The fix adds the same Parameters guard to the first loop, consistent with
the pattern already used in PopulateDefaultResourceInteractions(),
SyncSearchParameters()'s second loop, and SyncProfilesAsync().

Fixes microsoft#5394
@rtmalikian rtmalikian requested a review from a team as a code owner June 18, 2026 02:28
@rtmalikian rtmalikian changed the title fix: exclude Parameters resource from SyncSearchParameters to prevent non-conformant CapabilityStatement fix: exclude Parameters from SyncSearchParameters (Fixes #3876) Jun 19, 2026
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.

CapabilityStatement returned by the /metadata route does not conform to the FHIR standard

1 participant