Repository navigation
Handle defaultMeasureId 0 when creating and editing custom foods - #4
Merged
Merged
Conversation
Cronometer stores a custom food whose only measure is "g" (1 g) with defaultMeasureId 0, so add_custom_food(serving_name="g", serving_grams=1) failed after creating the food, and update_custom_food refused it. - create_custom_food takes the food's one measure instead of the default. - _default_measure treats id 0 as "no explicit default": the sole measure is the default; several measures are refused as ambiguous. - create_recipe identifies its serving as the one non-fixed measure, as update_recipe already does, instead of trusting defaultMeasureId. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only resolve the default measure when the serving or per-serving nutrients change; a rename never touches it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Regression from #3: Cronometer stores a custom food whose only measure is `g` (1 g) with `defaultMeasureId: 0` (verified live). `add_custom_food(serving_name="g", serving_grams=1)` then failed with "has no measure 0 after saving" even though the food was created, and `update_custom_food` refused such foods.
FakeFoodServer now keeps `defaultMeasureId` 0 for a lone `g` measure. 562 tests pass; 5 mutations of the new branches are all caught. Live: created, renamed and retired a throwaway `g`/1 g food.
🤖 Generated with Claude Code