Skip to content

fix: add barcode validation to image deletion and product update processes#1541

Merged
alexgarel merged 4 commits intoopenfoodfacts:mainfrom
areebahmeddd:issues/1445/barcode-valueerror
Apr 15, 2025
Merged

fix: add barcode validation to image deletion and product update processes#1541
alexgarel merged 4 commits intoopenfoodfacts:mainfrom
areebahmeddd:issues/1445/barcode-valueerror

Conversation

@areebahmeddd
Copy link
Member

Signed-off-by: Areeb Ahmed (areebshariff@acm.org)

Summary of Changes

  • Fix ValueError in update_insights_job by validating empty barcodes
  • Add barcode validation in delete_images to handle deleted products

Related Issues

Closes #1445

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@areebahmeddd could we change the implementation ?

My proposal: add a is_valid method on ProductIdentifier

For now it will check that:
product_id is not empty, and server_type is not empty and part of ServerType.

Call this method there before processing.

This would be more exact and also more easy to generalize, and in the futur we might add more checks.

@areebahmeddd
Copy link
Member Author

Done : ) I hope the recent commit reflects what you suggested above
Thanks

cc: @alexgarel

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @areebahmeddd this is good !

@alexgarel alexgarel merged commit bd8c081 into openfoodfacts:main Apr 15, 2025
5 checks passed
@areebahmeddd areebahmeddd deleted the issues/1445/barcode-valueerror branch April 15, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

ValueError: unknown barcode format:

2 participants