#10543·dapr

Bulk publish drops request-level metadata for entries without their own metadata

Author: nelson-parenteCreated Sep 23, 2026Updated Sep 24, 2026
Labelskind/bug

In what area(s)?

/area runtime

What version of Dapr?

1.17.2, verified locally. 1.18.4 shows the same behavior in the report at dapr/python-sdk#1214. The code is unchanged on master.

Expected Behavior

Request-level metadata on a bulk publish applies to every entry. ttlInSeconds set on the request puts an expiration field on every cloud event envelope, the same way PublishEvent does.

Actual Behavior

Request-level metadata is merged into an entry only when that entry already carries metadata of its own. An entry with no metadata keeps a nil map, so pubsub.ApplyMetadata never sees ttlInSeconds and the envelope has no expiration. Other request-level keys, for example partitionKey, are dropped for those entries in the same way.

gRPC, pkg/api/grpc/grpc.go, bulkPublishEvent:

go
if entry.GetMetadata() != nil {
    entries[i].Metadata = utils.PopulateMetadataForBulkPublishEntry(in.GetMetadata(), entry.GetMetadata())
}

HTTP, pkg/api/http/http.go, onBulkPublish:

go
if entry.Metadata != nil {
    entries[i].Metadata = utils.PopulateMetadataForBulkPublishEntry(metadata, entry.Metadata)
}

utils.PopulateMetadataForBulkPublishEntry already accepts a nil entry map, so the guard only skips the merge.

Most SDK calls produce entries without metadata. go-sdk PublishEvents with []byte or string events and python-sdk publish_events both build entries from entry_id, event and content_type only. For those callers, request-level bulk metadata has no effect at all.

Steps to Reproduce the Problem

  1. dapr init with the default Redis pub/sub. Redis declares no native TTL feature, so the runtime writes expiration itself.
  2. Bulk publish two entries with request metadata ttlInSeconds=300. Give the first entry its own metadata, for example partitionKey=a. Give the second entry no metadata.
  3. Subscribe to the topic and read both cloud events.

The first event has expiration. The second event has none.

dapr/python-sdk#1228 has this as an integration test, tests/integration/test_pubsub.py::test_bulk_publish_metadata_reaches_each_event. With the SDK-side copy of request metadata disabled, the plain entry fails the expiration assertion against runtime 1.17.2.

Suggested fix

Remove the nil guard in both handlers and always call PopulateMetadataForBulkPublishEntry(requestMetadata, entry.Metadata). Entry keys keep precedence over request keys. rawPayload is read from the request-level metadata before the loop and is not affected.

dapr/python-sdk#1228 works around this in the SDK by copying publish_metadata onto every entry. The other SDKs still hit it.

Release Note

RELEASE NOTE: FIX Bulk publish applies request-level metadata, for example ttlInSeconds, to entries that carry no metadata of their own.