Skip to content

Local Testing: consumer-context-service against Staging

Local Testing: consumer-context-service against Staging

Section titled “Local Testing: consumer-context-service against Staging”

Run the consumer-context-service locally, pointing at Fetch staging upstream services. This gives you a real integration test without deploying to ECS.

  • Go 1.23+ installed
  • Network access to *.stage-services.fetchrewards.com (VPN required)
  • No Python sidecars needed for core functionality (brand/category/fuzzy-match degrade gracefully)
  • No Neo4j needed (graph endpoints return nil gracefully)
Terminal window
cd /Users/s.hollinger/experiments/pilot-agent/full-agent/consumer-context-service
go build -o server ./cmd/server/
Terminal window
ENVIRONMENT=local \
HTTP_PORT=9080 \
MCP_PORT=9081 \
FPS_BASE_URL="https://stage-fido-product-service.fetchrewards.com" \
FIDO_SEARCH_BASE_URL="https://stage-pam-ml-search.us-east-1.stage-services.fetchrewards.com" \
OFFER_SEARCH_BASE_URL="https://stage-offer-search-service.stage-ml.us-east-1.stage-services.fetchrewards.com" \
NELI_BASE_URL="https://stage-neli.fetchrewards.com" \
LIDAR_BASE_URL="https://stage-lidar-api.us-east-1.stage-services.fetchrewards.com" \
PURCHASE_HISTORY_BASE_URL="https://stage-purchase-history-service.fetchrewards.com" \
USER_SERVICE_BASE_URL="https://stage-user-service.fetchrewards.com" \
FIDORA_BASE_URL="https://stage-fido-assortment-service.us-east-1.stage-services.fetchrewards.com" \
OFFER_GUARDIAN_HOST="https://stage-offer-guardian.fetchrewards.com" \
OG_CACHE_ENABLED="false" \
BUTTON_BASE_URL="https://stage-button-merchant-service.us-east-1.stage-services.fetchrewards.com" \
RETAILER_BASE_URL="https://stage-retailer-service.fetchrewards.com" \
ERECEIPT_BASE_URL="https://stage-ereceipt-provider-service.fetchrewards.com" \
FIDO_INDEX_REFRESH="0" \
./server
  • HTTP_PORT=9080 / MCP_PORT=9081 avoids conflicts with Docker on 8080
  • FIDO_INDEX_REFRESH="0" disables the background FIDO index rebuild (avoids hitting OG /active endpoint on startup)
  • OG_CACHE_ENABLED="false" disables Kafka-backed OG cache (requires MSK brokers). Set OG_KAFKA_BROKERS and OG_CACHE_ENABLED=true if Kafka is accessible
  • Python sidecar URLs default to localhost — they’ll fail silently for purchase history enrichment
  • Neo4j is omitted — graph-dependent endpoints (candidates, history) return nil gracefully
  • Google search keys omitted — web search MCP tool unavailable

Fetch services use two URL patterns — external ALB and internal ALB:

PatternFormatExample
Externalhttps://stage-{service}.fetchrewards.comFPS, OG, Neli, PHS, Retailer, eReceipt, User Service
Internalhttps://stage-{service}.us-east-1.stage-services.fetchrewards.comFIDO Search, FIDORA, Button, LIDAR
Internal MLhttps://stage-{service}.stage-ml.us-east-1.stage-services.fetchrewards.comOffer Search
TransportDefaultLocal OverrideDescription
REST API80809080HTTP endpoints
MCP80819081MCP tool server

Use port 9080 if running with HTTP_PORT=9080 override. Known stage FIDO: 062ba603-6ed2-4b01-b017-c37dcf53e491 (cheerios-ish product from FPS).

Terminal window
curl http://localhost:9080/health
# Expected: {"status":"ok"}
Terminal window
# Known FIDO ID that exists in stage FPS:
curl http://localhost:9080/v1/products/062ba603-6ed2-4b01-b017-c37dcf53e491/context
# Note: FPS returns 404 for FIDOs not in its attribute store — service returns empty fields gracefully

Product context with full enrichment (FPS + offers + user data)

Section titled “Product context with full enrichment (FPS + offers + user data)”
Terminal window
curl "http://localhost:9080/v1/products/062ba603-6ed2-4b01-b017-c37dcf53e491/context?user_id={user_id}"
Terminal window
curl -X POST http://localhost:9080/v1/products/context \
-H 'Content-Type: application/json' \
-d '{"fido_ids": ["062ba603-6ed2-4b01-b017-c37dcf53e491"]}'
Terminal window
curl -X POST http://localhost:9080/v1/products/search \
-H 'Content-Type: application/json' \
-d '{"descriptions": ["organic milk"]}'
# Note: FIDO Search returns IDs that may not exist in FPS — product names may be empty

Offer search (Offer Search + optional Neli eligibility)

Section titled “Offer search (Offer Search + optional Neli eligibility)”
Terminal window
curl -X POST http://localhost:9080/v1/offers/search \
-H 'Content-Type: application/json' \
-d '{"query": "coffee", "limit": 5}'
# With eligibility filtering:
curl -X POST http://localhost:9080/v1/offers/search \
-H 'Content-Type: application/json' \
-d '{"query": "coffee", "limit": 5, "user_id": "some-user-id"}'

Offers for a product (Offer Guardian + FIDO Index)

Section titled “Offers for a product (Offer Guardian + FIDO Index)”
Terminal window
# Requires FIDO_INDEX_REFRESH > 0 to populate the FIDO reverse index
curl "http://localhost:9080/v1/products/{fido_id}/offers"
Terminal window
curl -X POST http://localhost:9080/v1/offers/search/nearby \
-H 'Content-Type: application/json' \
-d '{"latitude": 40.7128, "longitude": -74.006, "user_id": "some-user"}'
Terminal window
curl "http://localhost:9080/v1/users/{user_id}/purchases"
curl "http://localhost:9080/v1/users/{user_id}/purchases?category=Dairy&brand=Happy+Cow"
Terminal window
curl "http://localhost:9080/v1/users/{user_id}/profile"

Graph endpoints (require Neo4j — will return null without it)

Section titled “Graph endpoints (require Neo4j — will return null without it)”
Terminal window
curl "http://localhost:9080/v1/users/{user_id}/candidates?lookback_days=90"
curl "http://localhost:9080/v1/users/{user_id}/history?fido_id={fido_id}"

Stage service hostnames resolve within Fetch VPN. If you get DNS errors, check VPN connection.

Stage services use valid certs. If you see TLS errors, your system CA bundle may be outdated.

FPS returns 404 for FIDO IDs not in its attribute store. The service treats 404 as “not found” (empty product fields, not an error). FIDO Search may return IDs that don’t exist in FPS — this is a data mismatch between the ML search index and the FPS attribute store. Use known prod FIDO ID 062ba603-6ed2-4b01-b017-c37dcf53e491 for meaningful results.

If OG host is set but FIDO_INDEX_REFRESH=0, the FIDO index won’t be populated. GetOffersForProduct still works (direct OG call per FIDO), but the index-based reverse lookup won’t. Set FIDO_INDEX_REFRESH=“5m” to enable background indexing.

All env vars with defaults — see internal/config/config.go. Key cache TTL defaults:

CacheTTLMax Size
FPS metadata1h50,000
FIDORA retailer data15m20,000
Neli eligibility5m10,000
Button merchants24h50,000
Retailer venue type30m10,000