Skip to content

Merge pull request #252 from opportunity-hack/fix/volunteer-resolve-by-propel-id Fix volunteering identity resolution (propel_id + metadata fallback) + logging#253

Merged
gregv merged 3 commits into
mainfrom
develop
Jul 2, 2026
Merged

Merge pull request #252 from opportunity-hack/fix/volunteer-resolve-by-propel-id Fix volunteering identity resolution (propel_id + metadata fallback) + logging#253
gregv merged 3 commits into
mainfrom
develop

Conversation

@gregv

@gregv gregv commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What does the PR do?

A description of the changes proposed in the pull request.

Type of change

  • Breaking Change
  • Bug Fix
  • New Feature

Linked Issue

Related Issue: reference to a related issue

Make sure you have

  • Pulled from the default branch
  • Documented your changes
  • Linked the Issue
  • Appointed a reviewer (if any)

gregv and others added 3 commits June 30, 2026 08:27
…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
@gregv
gregv merged commit 01d5380 into main Jul 2, 2026
10 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.

1 participant