Skip to content

Fix nutrition photo analysis API integration and missing Anthropic config docs#31

Draft
Eliaaazzz with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-nutrition-card-issue
Draft

Fix nutrition photo analysis API integration and missing Anthropic config docs#31
Eliaaazzz with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-nutrition-card-issue

Conversation

Copilot AI commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

Food photo upload returned 500 errors due to frontend/backend API contract mismatches. Error logs showed duplicate /api/v1/api/v1/ paths and the backend expected different parameter names and response structures than the frontend provided.

Changes

API Integration Fixes

  • Fixed endpoint path: /nutrition/analyze/api/v1/nutrition/analyze in nutritionApi.ts
  • Fixed multipart parameter: fileimage in apiClient.ts to match backend @RequestParam("image")
  • Aligned response DTOs: detectedFoods/totalitems/totalNutrition to match backend FoodRecognitionResponse

Type Safety

  • Updated TypeScript interfaces to match backend DTOs (RecognizedFood, NutritionInfo)
  • Added converter function to transform backend response to UI format
  • Made nutrition field optional to match Java DTO (no @NotNull annotation)

Documentation

  • Added Anthropic API key setup to SETUP_API_KEYS.md (backend uses Claude Vision, not Gemini)
  • Updated .env.example with ANTHROPIC_API_KEY configuration
// Before
const response = await api.uploadImage('/nutrition/analyze', imageUri);
// Parameter sent as 'file', expected 'image'
// Expected response.detectedFoods, got response.items

// After
const response = await api.uploadImage('/api/v1/nutrition/analyze', imageUri);
const detectedItems = response.items.map(convertToDetectedFood);
setTotal(response.totalNutrition);

The issue description mentioned Gemini API - note that food recognition requires Anthropic Claude API key, not Gemini.

Original prompt

This section details on the original issue you should resolve

<issue_title>no nutrition card returned after adding a photo of food</issue_title>
<issue_description>{"code":5000,"message":"An unexpected error occurred. Please try again later.","timestamp":1764982592329,"path":"/api/v1/api/v1/me"}

Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/analyze:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
ReviewMealScreen.tsx:40 Food analysis failed: APIError: An unexpected error occurred. Please try again later.
at request (apiClient.ts:72:13)
at async Object.analyzeFoodImage (nutritionApi.ts:84:10)
at async analyze (ReviewMealScreen.tsx:36:26)
analyze @ ReviewMealScreen.tsx:40Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/nutrition/analyze:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
ReviewMealScreen.tsx:40 Food analysis failed: APIError: An unexpected error occurred. Please try again later.
at request (apiClient.ts:72:13)
at async Object.analyzeFoodImage (nutritionApi.ts:84:10)
at async analyze (ReviewMealScreen.tsx:36:26)
analyze @ ReviewMealScreen.tsx:40Understand this error
:8080/api/v1/api/v1/nutrition/summary/daily?userId=default-user:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/me:1 Failed to load resource: the server responded with a status of 500 ()Understand this error
:8080/api/v1/api/v1/me:1 Failed to load resource: the server responded with a status of 500 ()Understand this error

is it because i didn't activate my google cloud account though gemini api key is provided</issue_description>

<agent_instructions>please review fronted an...


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 6, 2025 01:06
Co-authored-by: Eliaaazzz <204549980+Eliaaazzz@users.noreply.github.com>
Co-authored-by: Eliaaazzz <204549980+Eliaaazzz@users.noreply.github.com>
Co-authored-by: Eliaaazzz <204549980+Eliaaazzz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error returning nutrition card after food photo upload Fix nutrition photo analysis API integration and missing Anthropic config docs Dec 6, 2025
Copilot AI requested a review from Eliaaazzz December 6, 2025 01:15
@Eliaaazzz

Copy link
Copy Markdown
Owner

no, I want to disable claude and switch to gemini 2.5 flash,

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.

no nutrition card returned after adding a photo of food

2 participants