fix: accept benefit weight of 0 when loading recipes - #272
Merged
Conversation
The benefit weight selector only offers values 0-4 (component/widget/benefit_row.py), where 0 means the benefit is disabled. But validate_benefit_data rejected any weight outside 1-7, so any recipe with a de-weighted (0) benefit failed to load — even recipes the app itself saved. Sanitizing such recipes silently reset those 0 weights to the default 4, changing the user's analysis. Align the validator with the actual selectable range (0-4) and update the test fixture assertion that was encoding the old sanitized output.
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.
Problem
Recipes with a de-weighted benefit (weight
0) fail to load with:The benefit weight selector only offers values 0–4, where 0 means the benefit is disabled. But
validate_benefit_dataenforced1 ≤ weight ≤ 7— rejecting the legitimate0and permitting values the UI can never produce. The "sanitize" path then silently reset those0weights to the default4, changing the user's analysis.Fix
validate_benefit_datawith the actual selectable range:0 ≤ weight ≤ 4.0, the full0–4range, and out-of-range values.Full suite: 104 passed.