microsoft / azurechat

🤖 💼 Azure Chat Solution Accelerator powered by Azure Open AI Service
MIT License
1.2k stars 1.12k forks source link

Application error: a server-side exception has occurred (see the server logs for more information). #164

Closed riosengineer closed 1 year ago

riosengineer commented 1 year ago

Hi,

I've completed the full deployed as per the documentation:

However, when browsing to the Azure App URL and selecting the M365 sign in, and authenticating the page displays:

Application error: a server-side exception has occurred (see the server logs for more information). Digest: 22627551

This is on the main landing page https://*.azurewebsites.net/chat

I've connected App Insights and can see the following failures, if they are relevant?

404 - GET /robots933456.txt 0 - GET /

Networking Dev Tools tab in Edge shows:

bf6a786c-a09eeb97c0ca264c.js:9 Uncaught Error: Minified React error #419; visit https://reactjs.org/docs/error-decoder.html?invariant=419 for the full message or use the non-minified dev environment for full errors and additional helpful warnings. at bf6a786c-a09eeb97c0ca264c.js:9:63012 at lB (bf6a786c-a09eeb97c0ca264c.js:9:63885) at oT (bf6a786c-a09eeb97c0ca264c.js:9:119391) at uG (bf6a786c-a09eeb97c0ca264c.js:9:93436) at bf6a786c-a09eeb97c0ca264c.js:9:93258 at uX (bf6a786c-a09eeb97c0ca264c.js:9:93265) at n2 (bf6a786c-a09eeb97c0ca264c.js:9:37230) at bf6a786c-a09eeb97c0ca264c.js:9:106711 at u1 (bf6a786c-a09eeb97c0ca264c.js:9:106719) at uU (bf6a786c-a09eeb97c0ca264c.js:9:91545)

Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error. window.console.error @ 114-12ced0921ee54262.js:1

The Azure OpenAI Studio chat works, so I know the models seem ok. How can we troubleshoot further? I have re-deployed multiple times.

Thanks

riosengineer commented 1 year ago

Any ideas @thivy?

thivy commented 1 year ago

Any ideas @thivy?

I am not able to identify the error message since it's omitted in prod build. If you run the same configuration locally do you see the same any error?

riosengineer commented 1 year ago

Any ideas @thivy?

I am not able to identify the error message since it's omitted in prod build. If you run the same configuration locally do you see the same any error?

Local deployment works fine, using the same identity registration with amended redirect URI for localhost.

I actually am able to sign in successfully when using a different Azure AD account. Previously I was using an account with an .onmicrosoft domain in a sandbox tenant, which may be why (or license requirements)? Either way it would be good to understand the troubleshooting areas to help out.

davidxw commented 1 year ago

Hi @riosengineer - can you enable the Web App Log Stream and watch that for the error?

@thivy we need to make it easier to get errors out of the app when deployed to production

jorupp commented 1 year ago

re: better way to get errors out - one way would be adding integration with Application Insights (or whatever the currently-recommend Azure approach to that is). I've been exploring this (but not having a lot of luck with it) for another NextJS 13 application w/ app-router. I've run into a few issues (one of which - https://github.com/microsoft/ApplicationInsights-JS/issues/2149 / https://github.com/vercel/next.js/discussions/55405 - should be fixed soon in the AppInsights client-side SDK), but the biggest issue has been trying to get the client -> server -> dependency traces to all link up (or even all the dependencies to auto-register), plus the hacky way I approached getting the server-side initialization to run reliably at the right times.

I'd love to see a good example of that integration with NextJS 13 - here or otherwise (though I understand it's probably a bit outside the goal of this project).

riosengineer commented 1 year ago

Hi @riosengineer - can you enable the Web App Log Stream and watch that for the error?

@thivy we need to make it easier to get errors out of the app when deployed to production

2023-09-20T08:44:38.129221914Z at hashValue (/home/site/wwwroot/.next/server/chunks/420.js:38:10) 2023-09-20T08:44:38.129226414Z at userHashedId (/home/site/wwwroot/.next/server/chunks/420.js:32:16) 2023-09-20T08:44:38.129230714Z at async FindAllChatThreadForCurrentUser (/home/site/wwwroot/.next/server/chunks/420.js:421:24) 2023-09-20T08:44:38.129235014Z at async ChatMenu (/home/site/wwwroot/.next/server/chunks/365.js:369:19) { 2023-09-20T08:44:38.129238614Z code: 'ERR_INVALID_ARG_TYPE' 2023-09-20T08:44:38.129242214Z } 2023-09-20T08:44:38.131418003Z [Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] { 2023-09-20T08:44:38.131432503Z digest: '421095999' 2023-09-20T08:44:38.131437103Z }

Just to confirm, it works when using an Azure AD account with a corporate domain. e.g. dan@somecorpdomain.com

This issue only happens when I try with my sandbox Azure AD account which has an e.g. dan@testtenant.onmicrosoft UPN.

Is this possibly because OpenAI is looking specifically for my corporate domain for connectivity or something like that?

riosengineer commented 1 year ago

After checking everything over, I believe this is because we were using a different domain than the one we signed up for the OpenAI access with. However, it would be great to get some more informative errors.