DB056 – Finalise Ingredient Data Quality - #230
Merged
Merged
Conversation
1 task
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.
Ticket
Description
Reviewed the release dataset's ingredient fields against the actual cleaning code and found a real, release-critical bug:
cleanProductData.py's ingredient cleaning checked for the post-rename camelCase column names (ingredientsText,ingredients) before the rename step actually happens, soclean_ingredients_text()/clean_ingredients_list()and a per-record safety-net pass silently never ran against the real data.Confirmed with real evidence, not a hypothetical: the committed sample shows the Tuna product's empty
ingredients_textlanding in the cleaned output as"ingredientsText": ""instead ofnull— exactly the kind of inconsistent ingredient data this ticket asks to fix.Fix: two small column-name corrections in
database/clean_data/cleanProductData.py— no change to the cleaning logic itself, just fixing when it runs, so it actually operates on the real (still snake_case) column names at that point in the pipeline instead of silently creating a duplicate, blank shadow column.Verified safe:
detect_allergens()already has a defensiveingredientsText or ingredients_textfallback — needs no change, and now transparently receives cleaned instead of raw text.missing_field_handler.pyalready treatsingredients_textas a critical field alias — missing ingredient data is correctly flagged, not a pipeline failure.normalize_string/normalize_listareNone-safe by design.Documented, not fixed (out of ingredient scope): the same wrong-column-name bug class exists for
productQuantity/servingQuantity— flagged as a follow-up ticket rather than opportunistically fixed here.Full detail, before/after evidence, and the acceptance-criteria checklist are in
Documents/Database/2026 Trimester 1/DB056-Ingredient-Data-Quality-Finalisation.md.Files changed
database/clean_data/cleanProductData.py(bug fix — two column-name corrections)test/test_ingredient_cleaning_db056.py(new — 3 regression tests)Documents/Database/2026 Trimester 1/DB056-Ingredient-Data-Quality-Finalisation.md(new)Checks
test/test_ingredient_cleaning_db056.py, 3 new testsScreenshots
N/A — backend data-cleaning fix, no frontend/UI involved. Test output requested below as evidence instead.
How to verify
The first command should show all 3 new tests passing, in particular confirming the Tuna product's
ingredientsTextis nownullrather than"". The second confirms no regressions in existing cleaning/validation tests.