Align SoF async export to the simplified async interaction pattern#155
Merged
Merged
Conversation
Updates the $viewdefinition-export and $sqlquery-export operations to follow the FHIR Asynchronous Interaction Request Pattern per HL7/sql-on-fhir#369, replacing the prior Bulk Data completion behavior. Completion and failure are now both signalled by a 303 See Other redirect from the status poll to a separate result URL with an empty body. The new GET /export/{job_id}/result endpoint returns the manifest Parameters with 200 OK on success, or the error status code with an OperationOutcome on failure (404 when the job is unknown, cancelled, or not yet finished). The status endpoint no longer carries the job outcome. - Add get_export_result_handler and the /export/{job_id}/result route (static segment takes priority over the {filename} download route). - Status poll Completed/Failed arms now return 303 + Location to the result URL; Expires (24h) moves to the result response. - Update sof_export tests to follow the 303 -> result flow and add coverage for the redirect contract and the unknown-job result 404.
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.
Summary
Updates the
$viewdefinition-exportand$sqlquery-exportoperations to follow the FHIR Asynchronous Interaction Request Pattern per HL7/sql-on-fhir#369, replacing the prior Bulk Data completion behavior.The core behavioral change: completion (and failure) is now signalled by a
303 See Otherredirect from the status poll to a separate result URL — instead of returning200 OKwith the manifest directly on the status poll.Changes
crates/restrouting/fhir_routes.rs— AddedGET /export/{job_id}/result. The staticresultsegment takes priority over the existing{filename}download route (matchit 0.8 supports this overlap).handlers/sof/export.rsget_export_status_handler— theCompleted/Failedarms now return303 See Otherwith an empty body and aLocationheader carrying the absolute result URL. The status endpoint no longer communicates job outcome (still202while running,404for unknown/cancelled).get_export_result_handler— serves the manifestParameterswith200 OK+Expires(24h) on success, the error status +OperationOutcomeon failure, and404when the job is unknown/cancelled/still running.handlers/sof/mod.rs— re-exported the new handler.Tests (
crates/rest/tests/sof_export.rs)poll_to_manifesthelper to follow the303 → result URL → 200flow.200-on-poll completion, and the failure test (now asserts303 → 500at the result URL).test_export_completion_redirects_to_result(empty-body 303, Location, stable repeat fetch, Expires) andtest_export_result_unknown_job_returns_404.Not implemented (optional / client-side)
429 Too Many Requestsfor excessive polling — spec says the server MAY; we don't rate-limit polls.MUST; our URLs are already non-guessable (UUID job IDs).Caveat
HL7/sql-on-fhir#369 is still open, and the cited async-interaction pattern currently links an in-progress incubator branch — the exact
303/result-URL contract could shift before it lands.Test plan
cargo fmt --allcargo clippy --all-targets --all-features -- -D warnings ...(clean)cargo test -p helios-rest --test sof_export— 44 passed, 0 failed