fix(rest): execute search-style GET bundle entries as searches - #481
Open
angela-helios wants to merge 1 commit into
Open
fix(rest): execute search-style GET bundle entries as searches#481angela-helios wants to merge 1 commit into
angela-helios wants to merge 1 commit into
Conversation
Bundle GET entries were unconditionally parsed as Type/id reads, so a
search entry like 'Patient?name=x' became a read of resource type
'Patient?name=x' -- a 404 in batch bundles and a 400 rejecting the whole
bundle in transactions -- even though the spec allows any read OR search
URL in a GET entry.
The URL parser now strips the query string before extracting type/id,
and a GET entry addressing a type ('Patient?name=x', or bare 'Patient')
runs through the same search pipeline as the HTTP search endpoint
(terminology expansion, list/chain resolution, includes), embedding the
searchset Bundle as the entry resource. Instance reads ('Patient/123')
are untouched.
In transactions the spec orders GETs after all writes, and a search
cannot run inside the storage transaction, so search entries execute
against the just-committed state -- which also makes them see the
bundle's own writes. Their queries are validated up front so a
malformed search still rejects the whole bundle before anything
executes; a post-commit execution failure surfaces as that entry's own
error outcome rather than a misleading whole-bundle failure for writes
that did commit.
Closes #478
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Closes #478
The bug
Bundle GET entries were unconditionally parsed as
Type/idreads.GET Patient?name=Nguyenbecame a read of resource typePatient?name=Nguyen— a 404 in batch bundles, and a 400 rejecting the whole bundle in transactions — even though the spec's processing rules allow any read or search URL in a GET entry (this is what blocked the #476 screenshot bundle and got the bug filed).The fix
parse_request_urlstrips the query string before extracting type/id, so scope checks and reads see the real resource type.Patient?name=x, or barePatient) now runs through the same search pipeline as the HTTP endpoint (execute_search_bundle, factored out of the search handler): terminology expansion,_list/chain resolution,_include, paging clamps. The resulting searchset Bundle is embedded as the entry's resource with200 OK. Instance reads (Patient/123) are untouched.GET Patient?family=Tranin one transaction finds it). Their queries are validated up front, so a malformed search still rejects the whole bundle before anything executes; a post-commit execution failure surfaces as that entry's own error outcome rather than a misleading whole-bundle failure for writes that did commit. GET-by-id keeps running inside the storage transaction as before.Tests
New
search_entriesconformance tests: batch search entry returns a searchset, bare-type GET is a search, batch mixing read + search entries, transaction search seeing the bundle's own writes, transaction GET-by-id unchanged. Full helios-rest suite green (33 test binaries, incl. batch_conformance 44, search_integration 101, rest_conformance 84); clippy clean.