Skip to content

Fix critical auth, nutrition cache, and allergen regressions - #8

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-b14a
Draft

Fix critical auth, nutrition cache, and allergen regressions#8
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-b14a

Conversation

@cursor

@cursor cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown

Bug and impact

  • Token refresh returned valid auth tokens without provisioning a missing app users row, leaving affected sessions with GET /users/me 404s and downstream foreign-key 500s on meal-log/profile writes.
  • Daily nutrition summaries could stay stale for up to 24h after meal-log create/delete because cached daily totals were not invalidated.
  • Authenticated Spoonacular recipe searches did not send user allergens upstream, and the local DB allergen filter only matched exact spellings such as peanuts vs peanut.

Root cause

  • Signup/login self-healing was not mirrored in refreshSession.
  • MealLogService wrote/deleted rows without clearing nutrition:daily:{userId}:{date}.
  • Recipe search ignored the existing Spoonacular intolerances option and the DB query used unexpanded allergen strings.

Fix

  • Added shared auth user provisioning for signup/login/refresh and explicit no-email handling.
  • Added daily nutrition cache invalidation after meal-log create/delete.
  • Added FDA allergen alias expansion for local catalog filtering and mapped user allergens to Spoonacular intolerances with allergen-specific search cache keys.
  • Added focused backend tests for all three regressions.

Validation

  • pnpm exec prettier --check apps/backend/src/services/auth.service.ts apps/backend/src/services/meal-log.service.ts apps/backend/src/services/nutrition.service.ts apps/backend/src/services/recipe.service.ts apps/backend/tests/auth.test.ts apps/backend/tests/meal-log.test.ts apps/backend/tests/recipe.service.test.ts
  • pnpm --filter @snacktrack/backend test
  • pnpm --filter @snacktrack/backend lint
  • DATABASE_URL=postgresql://localhost:5432/snacktrack_test DIRECT_URL=postgresql://localhost:5432/snacktrack_test pnpm --filter @snacktrack/backend build
Open in Web View Automation 

cursoragent and others added 2 commits June 11, 2026 11:09
Co-authored-by: Vasanth Panuganti <vpanuga2@asu.edu>
Co-authored-by: Vasanth Panuganti <vpanuga2@asu.edu>
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