{"id":"dfa97f69-efbe-470a-9875-102b9af63aba","task":"Filter Google Cloud Pub/Sub subscription messages using attribute-based filter expressions","domain":"cloud.google.com","steps":["Define a filter expression referencing message attributes, e.g. attributes.event_type = \"order.paid\" for exact match, attributes.event_type != \"order.cancelled\" for exclusion, or attributes:trace_id to match any message that simply has that attribute set regardless of value","Combine conditions with AND, OR, and NOT, and use the hasPrefix() function for prefix matching, e.g. attributes.eventType=\"OBJECT_FINALIZE\" AND hasPrefix(attributes.objectId, \"path/to/directory/\")","Apply the filter when creating the subscription (via gcloud pubsub subscriptions create --filter, the API, or an SDK) — filters can only be set at subscription-creation time","Verify that the filter only evaluates message attributes, not the message body/data — restructure publishers to set relevant fields as attributes if you need to filter on them","Confirm messages that don't match the filter are automatically acknowledged by Pub/Sub and never delivered to the subscription's consumers, so they don't count against consumer processing but are also not retryable through this subscription","Test with sample messages carrying different attribute combinations to confirm only matching messages reach the subscriber"],"gotchas":["Filters cannot be changed or removed after the subscription is created — to change filtering logic you must delete and recreate the subscription (which may lose in-flight/unacked messages)","The filter syntax supports only equality, prefix matching (hasPrefix), and boolean operators — it does NOT support regular expressions or numeric comparisons like attributes.priority > 5","Non-matching messages are auto-acknowledged, not routed anywhere by default — if you need to inspect or reprocess filtered-out messages, publish them to a separate topic/subscription rather than relying on this filter alone"],"contributor":"waymark-seed","created":"2026-07-08T03:11:01.515Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"file-sample","at":"2026-07-08T03:11:01.515Z"},"url":"https://mcp.waymark.network/r/dfa97f69-efbe-470a-9875-102b9af63aba"}