omi icon indicating copy to clipboard operation
omi copied to clipboard

Open Food Facts: plain-text food search is routed to the non-full-text v2 API

Open kaijakagi-sys opened this issue 2 months ago • 2 comments

Problem and evidence

The Open Food Facts integration advertises packaged-food search by name (for example, “oat milk”), but _search_foods sends the plain-text query as search_terms to /api/v2/search.

  • Pinned Omi source: _search_foods, the search_foods manifest entry, and the query-based branch of tool_check_allergens.
  • Pinned official Open Food Facts API cheatsheet explicitly states: “Full-text search is not available in the v2 or v3 server-side API.” It describes v2 as structured/filter-based search, points toward Search-a-licious, and says the legacy /cgi/search.pl keyword-search endpoint is not recommended for new integrations.

This is a source/documented-contract mismatch, not a claim of live unrelated search results. I have not queried the provider or tested a deployed Omi app. Both pinned files byte-match the main-branch copies inspected today.

An offline capture executed the unchanged _search_foods function extracted from the pinned source, replacing the network boundary and product summarizer with fixtures. Both oat milk and peanut butter were routed to /api/v2/search with search_terms. Blank input made no request, and a synthetic upstream error propagated. These checks establish request routing only; they do not establish provider behavior or search relevance. The original merged #7448 introduced the same request shape; its live-request note does not establish that the text query filtered results.

Proposed bounded scope

Align the existing food-name search with a maintainer-approved, supported text-search contract, including the query-based allergen lookup that shares _search_foods. Keep direct barcode lookup and barcode-based comparisons unchanged.

Before implementation, agree whether to integrate the supported text-search backend or explicitly report that text search is unavailable until the provider route is ready. I would not silently substitute a tag filter or choose the discouraged legacy endpoint without agreement.

Validation would include hermetic production-handler checks for query forwarding, compatible response mapping, empty input, no results, provider errors, and the query-based allergen flow; barcode regression controls; applicable repository preflight/invariant and metadata checks. Any optional live smoke test would be reported separately and would check query effect, not merely HTTP success.

Scope and reward question

Following the contribution guide's bounty-suggestion invitation, @josancamon19: is this integration supported, which text-search strategy should it use, and would you consider a US$25 proposed bounty for the agreed bounded fix and regression tests after acceptance and merge? No bounty approval, funding, implementation, or payment is assumed.

kaijakagi-sys avatar Sep 08 '26 19:09 kaijakagi-sys

Hi @josancamon19 @kodjima33,

I reviewed the Open Food Facts API contracts and the implementation in plugins/omi-openfoodfacts-app/main.py.

The current /api/v2/search endpoint ignores unstructured text in search_terms. We can resolve this by routing plain-text queries to Open Food Facts' supported search endpoint while preserving:

  • Full response normalization (_summarize_product)
  • Barcode lookup (_lookup_barcode) and comparison contracts untouched
  • Query-based allergen checking (tool_check_allergens)
  • Hermetic regression tests covering query forwarding, empty inputs, no results, and upstream errors

Could you confirm if this scope is approved for the proposed US$25 bounty upon completion and merge? Once confirmed, I will submit a clean PR with all repository preflight checks passing.

Aj2280 avatar Sep 10 '26 14:09 Aj2280

Included in PR #13526 along with #13272. Search now uses /cgi/search.pl.

Nukeys avatar Sep 11 '26 20:09 Nukeys