fix(verified-reviews): send a JSON content-type to the reviews API

MA
1mo ago
+10-4

Problem

Verified Reviews loaders return no rating and no reviews. POST https://awsapis3.netreviews.eu/product now rejects the content-type a string body defaults to:

content-typestatus
application/json200
text/plain;charset=UTF-8 (fetch default for a string body)502
none415 FST_ERR_CTP_INVALID_MEDIA_TYPE

createClient sends no content-type, so rating, ratings and reviews fail. On deploy the catches swallow the error and return empty data, and console.error does not reach OTel, so nothing surfaces.

Change

  • verified-reviews/utils/client.ts: the 3 POSTs send content-type: application/json.
  • The context.isDeploy branches log through logger.error (with the HttpError) instead of console.error. The fullReview catch now uses its own label instead of the ratings one.

Verification

  • Same payload, before: HttpError 502. After: ratings and reviews returned (28 reviews, weighted rating 4.5 on a product group).
  • Forced isDeploy with a text/plain body: the failure is logged through logger.error and an empty result is returned without throwing.
  • Verified end to end on a VTEX storefront product page (reviews sheet and JSON-LD aggregateRating restored).
  • deno fmt --check and deno check verified-reviews/mod.ts pass.

🤖 Generated with Claude Code


Summary by cubic

Fixes Verified Reviews requests to the Netreviews product API by sending content-type: application/json, so ratings and reviews load again instead of failing with a 502. Deploy-side errors now go through logger.error so they surface in OTel instead of disappearing via console.error.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Verified Reviews requests that could fail with 502 responses by correctly identifying JSON request bodies.
    • Improved error reporting during deployment by routing errors through the application logger.