We're using the firestore-revenuecat-purchases-handler Firebase Extension, and we occasionally (not every time) see an error in Cloud Functions logs when a webhook event fires for a user who hasn't logged in yet (still on their RevenueCat anonymous ID):
Error saving user $RCAnonymousID:xxx:
Error: There is no user record corresponding to the provided identifier.
at setCustomClaims (/workspace/lib/index.js:75:38)It looks like the extension tries to call setCustomUserClaims() using the app_user_id from the event, and when that ID happens to still be an RC anonymous ID ($RCAnonymousID:...) rather than a real Firebase UID, admin.auth() can't find a matching user and throws. Since it's intermittent, my guess is this only happens when a webhook event fires before the user has been identified/logged in with their real Firebase UID.
Questions:
- Is this expected/known behavior, and safe to ignore since the claim will just be set correctly once the same user's event re-fires with their real Firebase UID after login?
- Is there a config option (or planned fix) to have the extension skip claim-setting for anonymous IDs instead of logging an error?
- If not, would a PR filtering out
$RCAnonymousID:prefixed IDs before callingsetCustomClaimsbe welcome?
Happy to open an issue/PR if this isn't already tracked — just wanted to check here first in case there's existing context.
Thanks!
