Skip to content

R5 topic-based Subscription creation fails on a partitioned server - SubscriptionValidatingInterceptor loses partition #8123

Description

@mrunibe

Summary

On a partitioned R5 server, creating a Subscription that references a SubscriptionTopic by URL fails with HTTP 500 / HAPI-1319. The topic exists and is active, but the validator looks it up with a SystemRequestDetails that has no partition context.

Steps to reproduce (using hapi-fhir-jpaserver-starter)

0. Start the server (R5, tenant partitioning, rest-hook enabled)

mvn -DskipTests -Dspring-boot.run.arguments="\
  --hapi.fhir.fhir_version=R5 \
  --hapi.fhir.subscription.resthook_enabled=true \
  --hapi.fhir.partitioning.allow_references_across_partitions=true \
  --hapi.fhir.request_tenant_partitioning_mode=true" \
  spring-boot:run

1. Register a SubscriptionTopic

curl -X PUT -H "Content-Type: application/fhir+json" \
  http://localhost:8080/fhir/DEFAULT/SubscriptionTopic/encounter-finished -d '{
  "resourceType": "SubscriptionTopic",
  "id": "encounter-finished",
  "url": "http://example.org/topic/encounter-finished",
  "status": "active",
  "resourceTrigger": [{
    "resource": "Encounter",
    "supportedInteraction": ["create", "update"],
    "queryCriteria": { "current": "Encounter?status=completed" }
  }]
}'

2. Create a Subscription pointing at the topic

curl -X POST -H "Content-Type: application/fhir+json" \
  http://localhost:8080/fhir/DEFAULT/Subscription -d '{
  "resourceType": "Subscription",
  "status": "requested",
  "topic": "http://example.org/topic/encounter-finished",
  "channelType": {
    "system": "http://terminology.hl7.org/CodeSystem/subscription-channel-type",
    "code": "rest-hook"
  },
  "endpoint": "http://localhost:9876",
  "contentType": "application/fhir+json"
}'

3. Observe

The POST returns HTTP 500:

{
  "resourceType": "OperationOutcome",
  "issue": [{
    "severity": "error",
    "code": "processing",
    "diagnostics": "HAPI-1319: No interceptor provided a value for pointcuts: [STORAGE_PARTITION_IDENTIFY_ANY, STORAGE_PARTITION_IDENTIFY_READ]"
  }]
}

Server log:

ERROR BaseInterceptorService : Exception thrown by interceptor for pointcut STORAGE_PRESTORAGE_RESOURCE_CREATED:
  ca.uhn.fhir.rest.server.exceptions.InternalErrorException: HAPI-1319: No interceptor provided a value for
  pointcuts: [STORAGE_PARTITION_IDENTIFY_ANY, STORAGE_PARTITION_IDENTIFY_READ]
    at BaseRequestPartitionHelperSvc.determineReadPartitionForRequest(...)
    at SearchCoordinatorSvcImpl.registerSearch(...)
    at BaseHapiFhirResourceDao.search(...)
    at SubscriptionValidatingInterceptor.findSubscriptionTopicByUrl(...)
    at SubscriptionValidatingInterceptor.validateR5PlusTopicSubscription(...)
    at SubscriptionValidatingInterceptor.validateCriteria(...)
    at SubscriptionValidatingInterceptor.resourcePreCreate(...)

Root cause

SubscriptionValidatingInterceptor.findSubscriptionTopicByUrl() looks up the topic with a bare new SystemRequestDetails() that carries no partition context:

// SubscriptionValidatingInterceptor.java
IBundleProvider search = subscriptionTopicDao.search(map, new SystemRequestDetails());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions