Conversation
…hat time") Even after the lazy-create fix (#250), logging volunteer time still failed for existing users with "Couldn't log that time. Please try again." Root cause: _resolve_and_ensure_user identified the user ONLY via a live Slack/Google OAuth round-trip (get_oauth_user_from_propel_user_id). When that call returns None (expired/unavailable provider token, PropelAuth hiccup, or its 5-min negative cache), the WRITE 404'd even though the user clearly exists — and the READ masked it by returning empty data (so the page showed 0h with no error banner, exactly the reported symptom). This is NOT a locale/date-format issue: an <input type=date> always yields an ISO yyyy-MM-dd value regardless of locale. Fix: resolve identity by the stable, locally-stored propel_id first, and only fall back to the OAuth round-trip (which is still needed to lazily create a doc for brand-new users). - Add fetch_user_by_propel_id to db/{db,firestore,mem}.py (single-field equality query — auto-indexed, no composite index). propel_id is persisted on every profile save (insert_user / update_user / serialize_profile_metadata). - _resolve_and_ensure_user: propel_id lookup -> OAuth fallback + lazy-create. - Tests: api/users/tests/test_volunteer_resolve.py (4 cases, incl. "OAuth must not be called when propel_id resolves"). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…entity
Production logs confirmed the failure: get_oauth_user_from_propel_user_id
returns None for a user, so the WRITE 404s ("Couldn't log that time") while the
READ returns empty. propel_id-first resolution (this PR's first commit) fixes
existing users who have a doc with propel_id — but get_profile_metadata (which
creates the doc) ALSO depends on the same failing OAuth round-trip, so a user
whose OAuth has always failed may have no doc at all and still fail.
Close the gap so a broken provider token can never block volunteering:
- Add a 3rd resolution tier in _resolve_and_ensure_user: PropelAuth user
metadata via auth.fetch_user_metadata_by_user_id() (reliable; no provider
token). Resolve an existing doc by email (backfilling propel_id) or lazily
create one from the metadata. Once created/backfilled with propel_id, every
later request hits the no-external-call fast path.
- Add fetch_user_by_email to db/{db,firestore,mem}.py.
- Fix the logging gap that hid the root cause: log the PropelAuth oauth_token
response BODY (truncated) on non-200, and a debug line when serving a cached
negative result (a tight retry window otherwise shows only "could not
resolve" with no reason). The body reveals WHY (no linked OAuth connection,
token revoked, wrong PROPEL_AUTH_URL/KEY, etc.).
- Tests: 6 cases incl. metadata-by-email backfill and metadata create-on-miss.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…y-propel-id Fix volunteering identity resolution (propel_id + metadata fallback) + logging
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.
What does the PR do?
A description of the changes proposed in the pull request.
Type of change
Linked Issue
Related Issue: reference to a related issue
Make sure you have