Skip to content

fix(fhirpath): relay only OperationOutcome text from a failed terminology call - #2960

Open
angela-helios wants to merge 1 commit into
mainfrom
fix/fhirpath-terminology-error-body
Open

angela-helios wants to merge 1 commit into
mainfrom
fix/fhirpath-terminology-error-body

Conversation

@angela-helios

Copy link
Copy Markdown
Contributor

Stacked on #2901. This branch starts from #2901's branch so that Test FHIRPath passes against the current fhir-test-cases master; its commit leaves this diff once #2901 merges.

Closes #2959

Summary

A non-2xx terminology answer put its whole body into FhirPathError::TerminologyHttpError, which reaches fhirpath-server, HFS and sof-server callers. HTML error pages, proxy messages and stack traces were relayed as is, at any size.

read_response now builds the message from the status, plus, when the body is an OperationOutcome, the diagnostics (else details.text) of its issues, joined and cut to 500 characters. That keeps useful answers such as "ValueSet … not found". Any other body is not relayed: it goes to the debug log, cut to 2048 characters.

Tests

  • New: terminology_client::tests::an_error_relays_only_operation_outcome_text_cut_short, against a mock server answering 404:

    • an OperationOutcome's diagnostics are relayed;
    • an HTML page naming an internal host is not, and the message ends at the status;
    • a 5000-character diagnostic is cut, with an ellipsis.

    With the raw body relayed again, the HTML case fails: the message carries internal-host.corp: stack trace….

  • Changed: terminology_cloudflare_retry_limit_preserves_final_error and terminology_retry_limit_preserves_final_error asserted that the upstream body (the Cloudflare page, gateway unavailable) reached the message. They still check that the final status survives the retries, and now check that those bodies do not reach the message.

cargo test -p helios-fhirpath --lib terminology: 60 passed. Clippy on helios-fhirpath --all-targets is clean. No test in another crate depends on the old message.

…logy call

A non-2xx terminology answer put its whole body into the error that reaches
fhirpath-server, HFS and sof-server callers, so HTML pages, proxy messages
and stack traces were relayed at any size. The error now carries the status
and, for an OperationOutcome body, its issue diagnostics cut to 500
characters; any other body only goes to the debug log.

Closes #2959
@claude

claude Bot commented Nov 26, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

This branch has not been deployed

No deployments
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.

FHIRPath terminology errors relay the upstream response body verbatim to the caller

1 participant