-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PubSub: PubSubOptions.eventFilters not creating a filter #1475
Comments
I found a few problems with this issue:
|
The EventFilter is an implementation detail of the EventArc trigger which is backing a pubsub function. Setting the The code you saw that @taeoid wrote likely covers the EventArc integration or is test cases for it. |
PubSubOptions extends options.EventHandlerOptions that has:
the SDK doesn't add a filter at all (as far as i can see) it creates the subscription to the topic but ignores the filter ( see the screen shots) |
HI @Berlioz |
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: