ai icon indicating copy to clipboard operation
ai copied to clipboard

UseChat error messages suddenly not working

Open peterdresslar opened this issue 2 years ago • 1 comments

It seems as though something has caused the UseChat error messages to change and break. A small example I worked on last week for a the Anthropic provider worked fine--error message clearing hack notwithstanding--and displayed precisely what you would expect when error was defined and error.message was displayed in the DOM (e.g., 404: Not Authorized).

Now the same repo on the same version of ai assigns an entire HTML document into error.message:

<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><style data-next-hide-fouc="true">body{display:none}</style><noscript data-next-hide-fouc="true"><style>body{display:block}</style></noscript><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills.js?ts=1695148765874"></script><script src="/_next/static/chunks/webpack.js?ts=1695148765874" defer=""></script><script src="/_next/static/chunks/main.js?ts=1695148765874" defer=""></script><script src="/_next/static/chunks/pages/_app.js?ts=1695148765874" defer=""></script><script src="/_next/static/chunks/pages/_error.js?ts=1695148765874" defer=""></script><script src="/_next/static/development/_buildManifest.js?ts=1695148765874" defer=""></script><script src="/_next/static/development/_ssgManifest.js?ts=1695148765874" defer=""></script><noscript id="__next_css__DO_NOT_USE__"></noscript></head><body><div id="__next"></div><script src="/_next/static/chunks/react-refresh.js?ts=1695148765874"></script><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"development","isFallback":false,"err":{"name":"Error","source":"edge-server","message":"{\"error\":{\"type\":\"authentication_error\",\"message\":\"Invalid API Key\"}}","stack":"Error: {\"error\":{\"type\":\"authentication_error\",\"message\":\"Invalid API Key\"}}\n at APIError.generate (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@anthropic-ai/sdk/error.mjs:40:20)\n at Anthropic.makeStatusError (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@anthropic-ai/sdk/core.mjs:276:65)\n at Anthropic.makeRequest (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@anthropic-ai/sdk/core.mjs:321:30)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async POST (webpack-internal:///(rsc)/./app/api/chat/anthropic-sdk/route.ts:32:22)\n at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/esm/server/future/route-modules/app-route/module.js:220:37)"},"gip":true,"scriptLoader":[]}</script></body></html>

This also appears to be happening using OpenAI in the route instead of Anthropic. Did some underlying library change?

peterdresslar avatar Sep 19 '23 18:09 peterdresslar

I'm facing the same issue. Any ideas on how to solve it?

MaxBalaban avatar Dec 25 '23 03:12 MaxBalaban