Skip to content

fix(transaction): resolve conditional references before execution - #467

Open
angela-helios wants to merge 2 commits into
mainfrom
fix/459-bundle-reference-resolution
Open

fix(transaction): resolve conditional references before execution#467
angela-helios wants to merge 2 commits into
mainfrom
fix/459-bundle-reference-resolution

Conversation

@angela-helios

Copy link
Copy Markdown
Contributor

Closes #459

Conditional references (Type?query) passed through into storage verbatim, where nothing can search or resolve them — Synthea bundles name practitioners, organizations, and locations this way on every entry, so the #448 dataset ingested with hundreds of unresolvable references.

Per the transaction processing rules they now resolve against the server's content in a pre-pass before anything executes:

  • exactly one match → the reference is rewritten to Type/id;
  • zero or several matches → the bundle is rejected with a clear message (they are atomic, and silently storing junk was the old behavior).

Distinct references resolve once (bundles repeat the same location heavily) and each lookup searches with count=2 — enough to prove non-uniqueness. The pre-pass runs before write validation so validation sees the rewritten content. batch_handler/process_transaction gain a SearchProvider bound, which every backend and the route-level bound already satisfy.

Scope correction on the issue

The issue's other half — urn:uuid fullUrl rewriting — turned out to be a false alarm: replaying both a minimal transaction and a real Synthea bundle against a clean server shows references correctly rewritten. The dangling urns in the original report came from my #448 $bulk-submit NDJSON (raw bundle-entry resources extracted verbatim), not from the transaction path. Noted on #459.

Tests

Three new integration tests in batch_conformance (unique match rewritten into storage; zero matches reject; ambiguous match rejects); full helios-rest suite green (batch_conformance 42, search_integration 101, and the rest).

Conditional references (Type?query) passed through into storage
verbatim, where nothing can search or resolve them — Synthea bundles
name practitioners, organizations, and locations this way on every
entry. Per the transaction processing rules they now resolve against
the server's content before anything executes: exactly one match
rewrites the reference to Type/id, zero or several reject the bundle.
Distinct references resolve once (bundles repeat the same location
heavily), and the search runs with count=2 — enough to prove
non-uniqueness.

Investigating the issue's other half showed urn:uuid fullUrl rewriting
already works: the report's dangling urns came from NDJSON test data
that had extracted raw bundle-entry resources, not from the
transaction path.

Closes #459
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.14815% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/rest/src/handlers/batch.rs 98.14% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

transaction: bundle references are stored unresolved — urn:uuid fullUrls are not rewritten and conditional references are never resolved

2 participants