Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/v2/providers/eventarc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ export function onCustomEventPublished<T = any>(
func.run = handler;

const channel = opts.channel ?? "locations/us-central1/channels/firebase";
const channelRegionMatch = channel.match(/locations\/([^/]+)\/channels\//);
const triggerRegion = channelRegionMatch ? channelRegionMatch[1] : "us-central1";
Comment on lines +204 to +205
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The regex used to extract the region from the channel string is brittle. If the channel format changes or if the input does not match the expected pattern, it defaults to 'us-central1' silently. It would be safer to validate the channel format or use a more robust parsing method to avoid incorrect region assignment.


const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
const specificOpts = options.optionsToEndpoint(opts);
Expand All @@ -219,6 +221,7 @@ export function onCustomEventPublished<T = any>(
eventFilters: {},
retry: opts.retry ?? false,
channel,
region: triggerRegion,
},
};
convertIfPresent(endpoint.eventTrigger, opts, "eventFilters", "filters");
Expand Down