feat(tandoor): Fix nutrition import and add language-agnostic property mapping#877
feat(tandoor): Fix nutrition import and add language-agnostic property mapping#877CodeWithCJ merged 4 commits intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where nutrition data from Tandoor recipe imports was often missing or incorrect. The changes introduce a more robust and flexible mechanism for extracting nutrient information by prioritizing explicit nutrition objects, leveraging Tandoor's auto-calculated Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request significantly improves the Tandoor integration by adding support for food_properties and making the nutrient mapping language-agnostic through the use of slugs. While the inclusion of comprehensive unit tests is a great addition, it introduces potential security vulnerabilities. Specifically, the getRecipeDetails method is vulnerable to path traversal due to unvalidated input in URL construction, and both searchRecipes and getRecipeDetails allow sensitive headers to be overridden, leading to insecure header handling in API requests. Additionally, there are areas for improvement regarding the robustness of nutrition parsing and preventing potential crashes from invalid data.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request significantly improves the Tandoor integration by fixing an issue with nutrition data import and making the property mapping language-agnostic, with more robust logic for extracting nutritional values. However, a potential path traversal vulnerability was identified in the getRecipeDetails function where the id parameter is used to construct a URL without proper sanitization; this should be addressed by encoding the id parameter. Additionally, consider refactoring constant definitions and reducing code repetition to improve maintainability.
Tip
Help us review and merge your PR faster!
Please ensure you have completed the Checklist below.
For Frontend changes, please run
pnpm run validateto check for any errors.PRs that include tests and clear screenshots are highly preferred!
Description
Provide a brief summary of your changes.
Description
This PR fixes an issue where imported Tandoor recipes often appeared with 0g of nutrients and 0kcal because SparkyFitness was not reading the
food_propertiesfield where Tandoor stores auto-calculated data.Additionally, this change makes the Tandoor integration language-agnostic by leveraging internal slugs and standard API keys, ensuring that localized Tandoor instances (e.g., Spanish "Proteínas") map correctly without needing manual translations in the codebase.
Key Changes
food_properties.open_data_slug(e.g.,property-proteins) for reliable internal matching across all languages.nutritionobject/array.food_properties.properties.Verification Results
Passed 7 unit tests covering all new mapping scenarios, including the localized Spanish data structure provided by the user.
Related Issue
PR type [ ] Issue [x] New Feature [ ] Documentation
Linked Issue: # #515
Checklist
Please check all that apply:
pnpm run validate(especially for Frontend).en) translation file (if applicable).rls_policies.sqlfor any new user-specific tables.Screenshots (if applicable)
Before
[Insert screenshot/GIF here]
After
[Insert screenshot/GIF here]