Skip to content

feat(connectors): GTIN/barcode lookup adapter + fix stale authConfig on env-var updates#386

Merged
keysersoft merged 4 commits into
mainfrom
keysersoft/gtin-lookup-and-envvar-auth-fix
Jul 3, 2026
Merged

feat(connectors): GTIN/barcode lookup adapter + fix stale authConfig on env-var updates#386
keysersoft merged 4 commits into
mainfrom
keysersoft/gtin-lookup-and-envvar-auth-fix

Conversation

@keysersoft

Copy link
Copy Markdown
Contributor

1. New adapter: GTIN / Barcode Lookup (intl/gtin-lookup)

Resolve GTIN / EAN / UPC / ISBN barcodes to product data via four free public databases — no API key needed:

Tool Source Domain
gtin_lookup_food / _search_food Open Food Facts food & CPG (multilingual)
gtin_lookup_retail / _search_retail UPCitemdb general retail
gtin_lookup_beauty Open Beauty Facts cosmetics
gtin_lookup_book Google Books books (ISBN-13)

Every tool sets useProxy: true — these sources rate-limit per client IP (UPCitemdb ~100/day/IP, Google Books shared anonymous quota), so proxy routing is the point. Verified live (Nutella EAN 3017620422003, Diet Coke UPC, keyword search). Ships gtin-lookup.live.spec.ts.

2. Credential fix (root-caused from an MFR 401 in production)

A user fixed a mistyped MFR_USERNAME (leading space) in the UI, but requests kept failing with 401 while Postman worked. Cause, verified by decrypting the prod record: PUT /connectors/:id/env-vars only writes env_vars, while BASIC_AUTH & co. authenticate from the encrypted auth_config frozen at import — the UI showed the corrected value, auth kept using the stale one ( 1demo@…, hex 20 prefix).

  • updateEnvVars now re-resolves authConfig/baseUrl/headers from the catalog adapter template with the merged env vars (catalog-installed connectors only; update() re-encrypts).
  • Credential values are trimmed at adapter import and env-var update.

The affected prod record was already hot-fixed by re-encrypting auth_config with the trimmed username.

…on env-var updates

GTIN / Barcode Lookup (intl/gtin-lookup): resolve GTIN/EAN/UPC/ISBN
barcodes via four free public databases — Open Food Facts (food/CPG),
UPCitemdb (general retail), Open Beauty Facts (cosmetics), Google Books
(ISBN). No credentials required; every tool opts into the proxy
(useProxy) because these sources rate-limit per client IP. Verified live
(Nutella EAN, Diet Coke UPC, keyword search). Ships a live spec with
always-on static checks.

Credential handling fix (found debugging an MFR 401 in production):
- PUT /connectors/:id/env-vars only updated env_vars, while BASIC_AUTH &
  co. authenticate from the encrypted auth_config frozen at import — so
  editing credentials in the UI silently had no effect on auth. For
  catalog-installed connectors, re-resolve authConfig/baseUrl/headers
  from the adapter template with the merged env vars on every update.
- Trim credential values at adapter import and env-var update: a pasted
  leading space in MFR_USERNAME was encrypted into auth_config and
  produced 401s that were invisible in the UI.
@keysersoft
keysersoft requested a review from D3nisty as a code owner July 3, 2026 12:00
Comment thread packages/backend/src/adapters/adapters.service.ts Fixed
Comment thread packages/backend/src/connectors/connectors.controller.ts Fixed
Skip __proto__/constructor/prototype keys when trimming credential and
env-var values, resolving CodeQL js/remote-property-injection alerts.
Comment thread packages/backend/src/connectors/connectors.controller.ts Fixed
Object.create(null) is the canonical sanitizer for CodeQL
js/remote-property-injection — removes the prototype-pollution sink.
Comment thread packages/backend/src/adapters/adapters.service.ts Fixed
Comment thread packages/backend/src/connectors/connectors.controller.ts Fixed
Avoids the dynamic user-keyed property write that CodeQL flags as
js/remote-property-injection, while still trimming credential values.
@keysersoft
keysersoft merged commit 6541467 into main Jul 3, 2026
11 checks passed
@keysersoft
keysersoft deleted the keysersoft/gtin-lookup-and-envvar-auth-fix branch July 3, 2026 12:14
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants