You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create a function as below:
exports.specialMessageListener = onMessagePublished(
{
topic: "myTopic",
region: region,
eventFilters: [
{
attributes: "type",
value: "specialMessage",
},
],
} ,
myFunctionToHandleSpecialMessages
); `
Deploy the function. check the pubsub topic subscription details.
[REQUIRED] Expected behavior
when firebase is deployed the subscription filter is set and the firebase function only recives messages that match the subscription filter
[REQUIRED] Actual behavior
The filter is not set and the function is triggered on all pubsub messages sent to the topic
Were you able to successfully deploy your functions? yes
I don't think this is a bug so much as missing docs on how to add a filter to a pubsub subscription from firebase.
I have tried several ways to set the eventFilter and either I get a typescript error or the functions deploy but missing the filtters (see screen shoot under actual behavior).
In the docs the description is just says TODO (see below)
@taeold has several merges in firebase tools and functions repos that suggest the format should be like: eventTrigger: { eventType: "pubsub_event", eventFilter: [ { attribute: "resource", value: "my-storage-bucket", }. { attribute: "appId", value: "12345", }. ] }
this is then supported by the extensions documentation that has the same structure in the yaml example however PubSubOptions nor EventHandlerOptions don't have eventTrigger as a option. I have tried using eventFilter in the the PubSubOption like:
This deploys fine but it doesn't set the filter. I have tried several other ways to set the filter with no luck. Can you help with an example of what I have missed please.
Thank you for the help.
The text was updated successfully, but these errors were encountered:
The EventFilter is an implementation detail of the EventArc trigger which is backing a pubsub function. Setting the topic of a pubsub function causes the SDK to generate an EventTrigger containing that topic as its EventFilter; the PubSubOptions struct doesn't contain a field for eventFilter because it wouldn't do anything.
The code you saw that @taeoid wrote likely covers the EventArc integration or is test cases for it.
HI @Berlioz
you reply doesn't make sense given that the PubSubOption class extends the EventHandlerOptions and no filter is set at all when the functions are deployed. see my original question and follow up
Related issues
colerogers.change-eventfilters
dl-cf3v2-eventfitlers
colerogers.change-eventfilters
dl-cf3v2-cc-efs
[REQUIRED] Version info
node: v18.12.1
firebase-functions: 4.4.1
firebase-tools: 12.7.0
firebase-admin: 11.11.0
[REQUIRED] Test case
import { onMessagePublished, PubSubOptions, } from "firebase-functions/v2/pubsub"; exports.specialMessageListener = onMessagePublished( { topic: "myTopic", region: region, eventFilters: [ { attributes: "type", value: "specialMessage", }, ], } , myFunctionToHandleSpecialMessages ); function myFunctionToHandleSpecialMessages( event: CloudEvent<MessagePublishedData<any>> ): void { console.log(event.data.message.attributes); }
[REQUIRED] Steps to reproduce
create a function as below:
exports.specialMessageListener = onMessagePublished(
{
topic: "myTopic",
region: region,
eventFilters: [
{
attributes: "type",
value: "specialMessage",
},
],
} ,
myFunctionToHandleSpecialMessages
); `
Deploy the function. check the pubsub topic subscription details.
[REQUIRED] Expected behavior
when firebase is deployed the subscription filter is set and the firebase function only recives messages that match the subscription filter
[REQUIRED] Actual behavior
The filter is not set and the function is triggered on all pubsub messages sent to the topic
Were you able to successfully deploy your functions? yes
I don't think this is a bug so much as missing docs on how to add a filter to a pubsub subscription from firebase.
I have tried several ways to set the eventFilter and either I get a typescript error or the functions deploy but missing the filtters (see screen shoot under actual behavior).
In the docs the description is just says TODO (see below)
@taeold has several merges in firebase tools and functions repos that suggest the format should be like:
eventTrigger: { eventType: "pubsub_event", eventFilter: [ { attribute: "resource", value: "my-storage-bucket", }. { attribute: "appId", value: "12345", }. ] }
this is then supported by the extensions documentation that has the same structure in the yaml example however PubSubOptions nor EventHandlerOptions don't have
eventTrigger
as a option. I have tried usingeventFilter
in the thePubSubOption
like:onMessagePublished( { topic: "myTopic", region: region, eventFilters: [ { attributes: "type", value: "specalMessage", }, ], } , myFunctionToHandleSpecalMessages );
This deploys fine but it doesn't set the filter. I have tried several other ways to set the filter with no luck. Can you help with an example of what I have missed please.
Thank you for the help.
The text was updated successfully, but these errors were encountered: