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.
Problem
POST /__admin/Taskwith anAsyncInteractionJobalways fails with an uncaught exception:The
AsyncInteractionJobprofile constrainsinput[bundle].value[x]toReference (AsyncInteractionRequestBundle)andoutput[bundle].value[x]toReference (AsyncInteractionResponseBundle). To check those target profiles the HAPIInstanceValidatortries to resolve the reference, and the validator built inblaze.admin-api.validatorprovides no resource resolution service, so it throws.input[bundle]is1..1, so this is not avoidable by leaving fields out — everyAsyncInteractionJobhits it.AsyncInteractionJobis one of the four profilesallowed-profilesexplicitly permits for this endpoint, so a documented input crashes.The exception is not converted into an
OperationOutcome.wrap-error*iswhich only handles an exceptionally-completed future, not a synchronous throw from the handler. There is no try/catch in
blaze.servereither, so the throw reaches the container and the client gets a bare 500 instead of a FHIR error response.Reproduction
Verified against the current
mainby posting jobs through the admin API handler in a test:AsyncInteractionJob,status = ready, only the requiredinput[bundle]referenceResource resolution services not providedAsyncInteractionJobwithoutput[bundle]referencingBundle/fooAsyncInteractionJobwithoutput[bundle]referencingDocumentReference/…ReIndexJob(no reference-typed elements)The other three allowed profiles (
ReIndexJob,CompactJob,DiskPerfJob) have noReferenceelements with target profiles and are unaffected, which is why the existingcreate-job-testcases pass.Impact
No effect on normal operation: async interaction jobs are created by the
Prefer: respond-asyncpath viablaze.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
blaze.admin-api.validator(or configure the validator not to follow references), so target profile checks don't throw.wrap-error*also catch synchronous throws, so a validator failure yields anOperationOutcomerather 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/Taskwith a minimalAsyncInteractionJob.