Skip to content

fix(delete-user-data): gate RTDB deletion on a configured instance - #2988

Open
CorieW wants to merge 2 commits into
kitsfrom
fix/kits-delete-user-data-rtdb-gate
Open

fix(delete-user-data): gate RTDB deletion on a configured instance#2988
CorieW wants to merge 2 commits into
kitsfrom
fix/kits-delete-user-data-rtdb-gate

Conversation

@CorieW

@CorieW CorieW commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Restores the extension's RTDB deletion gate, tracked in Kits parity issues #2974 as the kit's deletion risk: the extension deletes only when rtdbPaths && databaseURL; the kit gated on rtdbPaths alone and deleted against whatever default RTDB instance the app resolved.
  • handleClear now requires getDatabaseUrl(rtdbInstance, rtdbLocation) to resolve before scheduling RTDB deletion, logging rtdbNotConfigured otherwise — matching the extension's behaviour with RTDB_PATHS set and SELECTED_DATABASE_INSTANCE empty.
  • Existing rtdb deletion tests gain explicit rtdbInstance / rtdbLocation config; a new test asserts paths are skipped (not deleted) when no instance is configured.

Testing

  • tsc --noEmit clean; all 85 tests pass (84 existing + 1 new skip-assertion).
  • End-to-end against a consumer project: kit rebuilt from this branch, npm packed, re-vendored into its function-kits source.
  • Runtime gate test against the shipped artifact (the packed lib, via the consumer install): rtdbPaths set with no instance → zero removals and the "Realtime Database paths are not configured, skipping" log; instance + location configured → deletes the expected path.
  • Live deploy of both delete-user-data codebases (a91f6c2e, recursive) — all 6 functions updated, 0 failures.

The extension deletes RTDB data only when `rtdbPaths && databaseURL`,
where the URL derives from SELECTED_DATABASE_INSTANCE. The kit gated on
`rtdbPaths` alone and then called `ctx.database.ref(path).remove()`
against whatever default instance the app resolves -- so RTDB_PATHS
with an empty SELECTED_DATABASE_INSTANCE could delete data from an
unintended database. Tracked in #2974 as the kit's deletion risk.

handleClear now requires getDatabaseUrl(rtdbInstance, rtdbLocation) to
resolve before scheduling RTDB deletion, logging rtdbNotConfigured
otherwise, matching the extension. Existing rtdb tests gain the
instance/location config; a new test asserts the skip.

@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 updates the user data deletion handler to ensure Realtime Database (RTDB) deletion only runs when a database URL can be successfully derived from the configured instance and location. This aligns the behavior with the extension and prevents deletion against unintended default instances. The tests have been updated to reflect these configuration requirements and verify that RTDB deletion is skipped when no database instance is configured. There are no review comments, and I have no additional feedback to provide.

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.

2 participants