{"record":{"id":"4a2d07d2011d0164","repo":"remotion-dev/remotion","slug":"unexpected-response-from-server-json-stringify","errorCode":null,"errorMessage":"Unexpected response from server: ${JSON.stringify(json)}","messagePattern":"Unexpected response from server: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/licensing/src/register-usage-event.ts","lineNumber":125,"sourceCode":"\t\t\t\t},\n\t\t\t\tsignal: abortController.signal,\n\t\t\t});\n\t\t\tclearTimeout(timeout);\n\n\t\t\tconst json = (await res.json()) as ApiResponse;\n\n\t\t\tif (json.success) {\n\t\t\t\treturn {\n\t\t\t\t\tbillable: json.billable,\n\t\t\t\t\tclassification: json.classification,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (!res.ok) {\n\t\t\t\tthrow new Error(json.error);\n\t\t\t}\n\n\t\t\tthrow new Error(\n\t\t\t\t`Unexpected response from server: ${JSON.stringify(json)}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tclearTimeout(timeout);\n\n\t\t\tconst error = err as Error;\n\t\t\tconst isTimeout = error.name === 'AbortError';\n\t\t\tconst isRetryable = isNetworkError(error) || isTimeout;\n\n\t\t\tif (!isRetryable) {\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tlastError = isTimeout\n\t\t\t\t? new Error('Request timed out after 10 seconds')\n\t\t\t\t: error;\n\n\t\t\tif (attempt < totalAttempts) {","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/licensing/src/register-usage-event.ts#L107-L143","documentation":"Defensive throw in internalRegisterUsageEvent for an unexpected contract violation: the server returned success:false but res.ok was true (HTTP 2xx). This should never happen against the real licensing API; it indicates a malformed/intercepted response, a man-in-the-middle (e.g. a proxy returning HTML), or a version skew between client and server.","triggerScenarios":"A corporate proxy or CDN intercepting the request and returning a 200 with a non-conforming JSON body; calling a mock/staging endpoint that does not implement the success:false contract; a future API change returning a new shape this client version does not understand.","commonSituations":"Behind a captive portal or Zscaler/ Netskope proxy that returns 200 + HTML; the licensing HOST was monkey-patched to a test server; an outdated @remotion/licensing version against a newer backend.","solutions":["Log the full json payload to see what the server actually returned.","Bypass any HTTP proxies intercepting requests to remotion.pro and retry.","Upgrade @remotion/licensing to match the rest of the Remotion packages.","If using a custom HOST, ensure the endpoint implements the documented response shape."],"exampleFix":"// before\nfetch behind corporate proxy -> 200 with HTML body\n// after\nexport HTTPS_PROXY='' && re-run; or upgrade @remotion/licensing to the installed Remotion version","handlingStrategy":"try-catch","validationCode":"// Pre-flight: ensure responses are JSON-shaped\nconst probe = await fetch('https://www.remotion.pro/api/track/health');\nif (!probe.headers.get('content-type')?.includes('application/json')) {\n  console.warn('Proxy may be intercepting remotion.pro traffic');\n}","typeGuard":"const isApiResponse = (j: unknown): boolean =>\n  typeof j === 'object' && j !== null && 'success' in j;","tryCatchPattern":"try {\n  await internalRegisterUsageEvent({...});\n} catch (e) {\n  if (/Unexpected response from server/i.test((e as Error).message)) {\n    // Likely a proxy interception; log full body for ops\n    console.error('Licensing API contract violation:', (e as Error).message);\n  } else throw e;\n}","preventionTips":["Bypass HTTP proxies for traffic to remotion.pro when possible.","Keep @remotion/licensing upgraded in lockstep with other Remotion packages.","If pinning a custom HOST for testing, ensure it returns the documented response shape.","Log full payloads when this defensive throw fires to diagnose interception."],"tags":["typescript","licensing","network","proxy","api-contract"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}