Repository navigation
fix(delete-user-data): reject invalid select and regex param values at deploy - #3278
Merged
Merged
Conversation
…t deploy Values already in .env skip the CLI's prompt-time validation, so the kit deployed with values the extension refuses at install time and then quietly did less, e.g. FIRESTORE_DELETE_MODE=RECURSIVE ran as shallow and ENABLE_AUTO_DISCOVERY=true left auto-discovery off. Check every param's declared select options and validationRegex at module load, so discovery fails with the param, the bad value and the allowed values. Fixes #3258
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces deploy-time validation for .env configuration parameters in the delete-user-data kit to prevent silent misconfigurations. It adds the assertValidParams function to validate parameter values against allowed options or regex patterns, calls this validation at module scope, updates the documentation and changelog, and includes comprehensive unit tests. The review feedback suggests a minor improvement in config.ts to avoid redundantly wrapping validationRegex in a new RegExp constructor if it is already a RegExp object.
This was referenced Oct 20, 2026
CorieW
commented
Oct 27, 2026
CorieW
commented
Oct 27, 2026
The extension only checks for `recursive` and `yes`, so `Shallow` and `No` ran exactly like their values. Only reject the labels it misread: `Recursive`, `Yes` and the location labels.
CorieW
marked this pull request as ready for review
October 27, 2026 12:53
IzaakGough
reviewed
Oct 27, 2026
Reverts the us-central1 default for a blank SELECTED_DATABASE_LOCATION. The extension skips RTDB paths when the location is blank, and the README documents that gate; defaulting it pointed EU instances at the US host.
assertRequiredParams() threw before assertValidParams() ran, so a .env with a blank required param and an invalid value needed two deploys to see both. assertParams() runs both checks and throws once with both messages.
…data-validate-params # Conflicts: # kits/delete-user-data/CHANGELOG.md # kits/delete-user-data/tests/index.test.ts
IzaakGough
approved these changes
Oct 27, 2026
The extension's installer accepted a select param's label as well as its value and ran it as-is, so Recursive deleted shallowly and Yes left auto-discovery off. The kit now accepts every label too and runs it the same way, rather than failing the deploy. The README warns what each label does.
Destructuring the optional label failed to type-check against the union of select option arrays, which broke the kit build.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rejects the
.envvalues the extension refuses at install time, so the kit's deploy fails instead of deploying and quietly deleting less data. Values the extension accepts, its option labels included, still deploy and run as they did in the extension. Fixes #3258 (part of #3249).Changes
assertValidParams()insrc/config.ts. It reads each param's declaredinput(no copied lists): a select value must be one of the option values or labels, and a text value must match itsvalidationRegex. The error names the param, the bad value and the allowed values, and lists every bad param at once.assertRequiredParams()(see decision(delete-user-data): kit/extension parity – blank required params fail the kit deploy, the extension uses defaults #3256).assertParams()runs both checks at module load and throws once, so a blank required param and an invalid value are reported in the same deploy.assertRequiredParams()itself is unchanged, as the other kits share it.Recursive,Shallow,Yes,No,United States,Belgium,Singapore) are accepted, as the extension's installer accepted them. They run as they did in the extension:Recursivedeletes shallowly,Yesleaves auto-discovery off, and a location label gives a database URL that doesn't exist. The README warns about this and says to use the values.tests/valid-params.test.tsandtests/index.test.ts. README (Configuration) and CHANGELOG updated.assertRequiredParams()/validatePathListsFromEnv()pattern. feat(storage-resize-images): reject unknown IMAGE_TYPE values at config resolve time #3124 was closed; fix(storage-resize-images): reject unsupported IMAGE_TYPE values #3169 (open, intonext) proposes theIMAGE_TYPEchecks.Example error:
Testing
Deployed on a test project: the extension
firebase/delete-user-data@0.1.30, the kit fromkitsand the fixed kit, each with its own Firestore database. Each hadFIRESTORE_PATHS=users/{UID}and was seeded withusers/<uid>,users/<uid>/sub/s1,things/t-<uid> {uid}and a control doc; then a test user was deleted.Bad values (extension checked with the instances API
validateOnly=true; kits with a realfirebase deploy):.envvalueFIRESTORE_DELETE_MODE=RECURSIVE/recursivexFIRESTORE_DELETE_MODE=Recursive(label)ENABLE_AUTO_DISCOVERY=true/YESSELECTED_DATABASE_LOCATION=us-east1/US-CENTRAL1SELECTED_DATABASE_INSTANCE=https://x.firebaseio.comCLOUD_STORAGE_BUCKET=gs://x/Upper_CaseSELECTED_DATABASE_INSTANCE/SELECTED_DATABASE_LOCATION¹ The deploy run rejected labels; accepting them came later (32a478f) and is covered by unit tests, not a fresh deploy.
The kit before deployed with all five bad values in one
.env; the runtime env held them as written.User deletion (extension and fixed kit with
recursive/yes, kit before withRECURSIVE/true):users/<uid>users/<uid>/sub/s1things/t-<uid>(uidfield, auto-discovery)The kit before logged
firestoreDeleteMode: "RECURSIVE",enableAutoDiscovery: falseand a non-recursive delete.Unit tests:
vitest runpasses (16 files, 165 tests), including every option label being accepted and a blank required param plus an invalid value being reported in one error. Prettier passes on the changed files.tscpasses, but only with a temporarily available@types/node: onkits,pnpm buildfails withTS2688: Cannot find type definition file for 'node'because@types/nodeisn't installed, which this change doesn't cause.Other kits read
.envthe same way and probably have the same gap.