Skip to content

fix(delete-user-data): validate EXT_SELECTED_EVENTS and EVENTARC_CHANNEL at deploy - #3286

Merged
CorieW merged 9 commits into
kitsfrom
fix/kits-delete-user-data-selected-events-spaces
Nov 10, 2026
Merged

CorieW merged 9 commits into
kitsfrom
fix/kits-delete-user-data-selected-events-spaces

Conversation

@CorieW

@CorieW CorieW commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Validates EXT_SELECTED_EVENTS and EVENTARC_CHANNEL when the kit loads, so values the extension's install rejected now fail the deploy instead of silently dropping events. Before, firebase-admin split the list on , without trimming, so a, b, c published only a, and typos or wrong case were dropped without a warning. Fixes #3259.

Changes

  • selectedEventTypes() runs at module load and fails the deploy, as the extension's install did, if:
    • an EXT_SELECTED_EVENTS entry has spaces or wrong case, isn't one of the three event types, or is repeated (repeats are reported first, as the platform did);
    • event types are listed but EVENTARC_CHANNEL is unset or empty;
    • EVENTARC_CHANNEL isn't a full projects/<project id>/locations/<location>/channels/<channel id> name, is in another project (GCLOUD_PROJECT), or isn't in one of the CLI's ALLOWED_EVENT_ARC_REGIONS. This is checked even with no event types selected, as on the extension.
  • Empty entries (,a,,b,) are still skipped, and an empty value still publishes nothing.
  • setupEventChannel passes the validated array to channel().
  • README Events section lists the rules. CHANGELOG entry and tests added.

Testing

On a test project with firebase-tools 15.31.0, I compared firebase/delete-user-data@0.1.30 with the kit from this branch. Extension values were sent with validateOnly=true, as the CLI sends them. Kit values were deployed with --dry-run, and every rejected value also as a real deploy, which failed and created nothing.

All 66 values were accepted or rejected the same way. Error wording differs but names the same entries. "Kit before" comes from the code on kits; the a, b, c and whitespace-only rows were also checked live.

A selection (a = firebase.extensions.delete-user-data.v1.firestore, b = …database, c = …storage):

Value Extension Kit before Kit after
a,b,c, ,a,,b,c, accepted; publishes a, b, c deploys; publishes a, b, c deploys; publishes a, b, c
,,, empty, unset accepted; publishes nothing deploys; publishes nothing deploys; publishes nothing
a, b, c rejected: ' b' and ' c' "is not listed in the extension spec" deploys; publishes only a fails: ' b' and ' c' "is not one of …"
" a,b ", " ", " , ,", wrong case, a;b rejected: not listed deploys; publishes nothing, no warning fails: not one of
bogus,b rejected: bogus not listed deploys; publishes only b fails: bogus not one of
a,a rejected: "specified multiple times" deploys; publishes a fails: "listed more than once"
types, no channel rejected: "Must specify eventarc channel…" deploys; publishes nothing fails with the same sentence
channel firebase-admin can't parse (missing location, trailing /, extra segment), with types rejected: "not a valid channel resource name" deploys; every run then fails with "Invalid channel name format", so no user data is deleted fails
bare channel id, or locations/<l>/channels/<c> rejected deploys; publishes to that channel in this project (us-central1 for a bare id) fails
channel in europe-west1, us-east1, global, a bogus region rejected: "location is not supported location" deploys; publishes there fails: "location '…' is not supported"
channel in another project, or the project number rejected: "must be in the same project" deploys; publishes there if allowed fails: "it must be in the same project"
any bad channel, no event types rejected deploys; the channel is never opened fails
channel in us-central1, us-west1, europe-west4, asia-northeast1 accepted deploys deploys
well-formed channel that doesn't exist accepted; the install creates it deploys; each publish logs a warning deploys; each publish logs a warning

Then I deployed both with a recorder function on my own channel and deleted a test user ("kit before" is again from the code):

Selection Extension Kit before Kit after
empty, channel set nothing nothing nothing
firestore firestore firestore firestore
database, storage database, storage database, storage database, storage
all three firestore, database, storage firestore, database, storage firestore, database, storage

GCLOUD_PROJECT is set at deploy, in deployed functions and in the emulator, so the project check runs in all three.

pnpm test passes (190 tests) and Prettier passes. tsc -b passes with @types/node temporarily installed; without it pnpm build fails, which this change doesn't cause.

firebase-admin splits a string allowlist on commas without trimming, so a hand-written list with spaces after the commas only allowed the first type. Split and trim the list before opening the channel, and treat a whitespace-only value as unset.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request fixes an issue where spaces in the EXT_SELECTED_EVENTS environment variable caused event types to be silently dropped. The list is now split, trimmed, and filtered to remove empty entries before being passed to firebase-admin. Additionally, the documentation, changelog, and tests have been updated to reflect and verify these changes. There are no review comments to address, so I have no feedback to provide.

Comment thread kits/delete-user-data/src/events.ts Resolved
Comment thread kits/delete-user-data/README.md Resolved
Comment thread kits/delete-user-data/src/events.ts Resolved
@CorieW
CorieW marked this pull request as ready for review October 27, 2026 16:19
@CorieW
CorieW marked this pull request as draft October 27, 2026 16:20
…nstead of trimming

The extension's install failed on spaces, wrong case, unknown types, duplicates or ';'. Validate the list at module load, next to assertRequiredParams(), so the deploy fails the same way.
…ension rejected

Keep the skipped-empty-entries case, expect a throw for wrong case, unknown types, duplicates and ';', and check that importing the kit with a bad value fails.
…nd a malformed channel

The extension's install rejected both ("Must specify eventarc channel if allowing some events to be emitted"); the kit silently turned events off.
…data-selected-events-spaces

# Conflicts:
#	kits/delete-user-data/CHANGELOG.md
#	kits/delete-user-data/src/index.ts
#	kits/delete-user-data/tests/index.test.ts
@CorieW CorieW changed the title fix(delete-user-data): trim event types in EXT_SELECTED_EVENTS fix(delete-user-data): validate EXT_SELECTED_EVENTS and EVENTARC_CHANNEL at deploy Nov 9, 2026
@CorieW
CorieW marked this pull request as ready for review November 10, 2026 10:45

@cabljac cabljac left a comment

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.

lgtm

@CorieW
CorieW merged commit 3ded546 into kits Nov 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(delete-user-data): kit/extension parity – spaces in EXT_SELECTED_EVENTS silently drop events

2 participants