Skip to content

fix: accept benefit weight of 0 when loading recipes - #272

Merged
dfguerrerom merged 1 commit into
mainfrom
fix/benefit-weight-zero-valid
Jun 22, 2026
Merged

fix: accept benefit weight of 0 when loading recipes#272
dfguerrerom merged 1 commit into
mainfrom
fix/benefit-weight-zero-valid

Conversation

@dfguerrerom

@dfguerrerom dfguerrerom commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Problem

Recipes with a de-weighted benefit (weight 0) fail to load with:

Weight must be between 1 and 7, got 0

The benefit weight selector only offers values 0–4, where 0 means the benefit is disabled. But validate_benefit_data enforced 1 ≤ weight ≤ 7 — rejecting the legitimate 0 and permitting values the UI can never produce. The "sanitize" path then silently reset those 0 weights to the default 4, changing the user's analysis.

Fix

  • Align validate_benefit_data with the actual selectable range: 0 ≤ weight ≤ 4.
  • Add unit tests covering weight 0, the full 0–4 range, and out-of-range values.

Full suite: 104 passed.

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.
@dfguerrerom
dfguerrerom merged commit 534e248 into main Jun 22, 2026
1 check passed
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