Skip to content

Fix Crash When Creating Async Interaction Jobs #3954

Description

@alexanderkiel

Problem

POST /__admin/Task with an AsyncInteractionJob always fails with an uncaught exception:

org.hl7.fhir.exceptions.FHIRException: Resource resolution services not provided
  at org.hl7.fhir.validation.instance.InstanceValidator.checkReference (InstanceValidator.java:5023)
  ...
  blaze.admin_api.validator/validate (validator.clj:170)
  blaze.admin_api/validate (admin_api.clj:205)
  blaze.admin_api/fn (admin_api.clj:215)          ; wrap-validate-job

The AsyncInteractionJob profile constrains input[bundle].value[x] to Reference (AsyncInteractionRequestBundle) and output[bundle].value[x] to Reference (AsyncInteractionResponseBundle). To check those target profiles the HAPI InstanceValidator tries to resolve the reference, and the validator built in blaze.admin-api.validator provides no resource resolution service, so it throws.

input[bundle] is 1..1, so this is not avoidable by leaving fields out — every AsyncInteractionJob hits it. AsyncInteractionJob is one of the four profiles allowed-profiles explicitly permits for this endpoint, so a documented input crashes.

The exception is not converted into an OperationOutcome. wrap-error* is

(defn wrap-error* [handler]
  (fn [request]
    (-> (handler request)
        (ac/exceptionally handler-util/error-response))))

which only handles an exceptionally-completed future, not a synchronous throw from the handler. There is no try/catch in blaze.server either, so the throw reaches the container and the client gets a bare 500 instead of a FHIR error response.

Reproduction

Verified against the current main by posting jobs through the admin API handler in a test:

Job Result
AsyncInteractionJob, status = ready, only the required input[bundle] reference throws Resource resolution services not provided
AsyncInteractionJob with output[bundle] referencing Bundle/foo throws
AsyncInteractionJob with output[bundle] referencing DocumentReference/… throws
ReIndexJob (no reference-typed elements) 201

The other three allowed profiles (ReIndexJob, CompactJob, DiskPerfJob) have no Reference elements with target profiles and are unaffected, which is why the existing create-job-test cases pass.

Impact

No effect on normal operation: async interaction jobs are created by the Prefer: respond-async path via blaze.job-scheduler/create-job, which does not go through the admin API validator. The bug is confined to creating such a job directly through the Admin API.

Possible fixes

  • Wire a resource resolution service into the validator in blaze.admin-api.validator (or configure the validator not to follow references), so target profile checks don't throw.
  • Independently, make wrap-error* also catch synchronous throws, so a validator failure yields an OperationOutcome rather than a container-level 500.

Notes

Found while investigating whether the page ID cipher key set is reachable through any API (see #3951, #3952). Regression test should cover a POST /__admin/Task with a minimal AsyncInteractionJob.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions