Skip to content

MealList: duplicate compound meal drops components; edit/save/replace errors swallowed #7

Description

@KrishP147

From code audit, frontend/src/components/MealList.jsx:

  1. Duplicate (~L168-183) inserts components with calories, protein_g, carbs_g, fat_g, fiber_g but meal_components only has NOT NULL base_* columns (backend/migrations/005_meal_tracking.sql:68-72). PostgREST rejects the insert, result unchecked → duplicated meal is is_compound=true with zero components.
  2. Edit/save (~L603-614, L666-671, L696-715) never reads error from component updates; meal update has no else branch, form stays open silently.
  3. Replace (handleReplaceSimpleMeal ~L567-581) ignores the update error and updates local state anyway.
  4. fetchMeals (~L53-58) crashes if user is null.

Fix: map duplicate to base_* columns and check error; surface an inline error on every failed Supabase call; only update local state after success; guard user.

Acceptance: tests for duplicate mapping + error surfacing; existing MealList-related tests green.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions