fix(chat): handle EasyAuth 302 redirect and improve auth error detection in useAgentCard#8801
Merged
ccastrotrejo merged 6 commits intomainfrom Feb 17, 2026
Merged
Conversation
🤖 AI PR Validation ReportPR Review ResultsThank you for your submission! Here's detailed feedback on your PR title and body compliance:✅ PR Title
✅ Commit Type
✅ Risk Level
✅ What & Why
✅ Impact of Change
✅ Test Plan
|
| Section | Status | Recommendation |
|---|---|---|
| Title | ✅ | None |
| Commit Type | ✅ | None |
| Risk Level | ✅ | None (advised risk: low) |
| What & Why | ✅ | Optionally mention changed file paths |
| Impact of Change | ✅ | None |
| Test Plan | ✅ | Consider noting the manual/EasyAuth test env |
| Contributors | Add contributor tags if applicable | |
| Screenshots/Videos | Not applicable |
Final Notes
- The code diff shows sensible, minimal changes: extraction of a small helper
handleUnauthorized, wrapping fetch in a try/catch to treat network/CORS errors as auth failures, switching to checking numeric HTTP status codes (401/403), and improving error messages. Unit tests were added/updated to cover the new behavior. Everything aligns with the PR body and therisk:lowlabel. - No changes are required to pass this PR review. If you want to be extra thorough you can:
- Add contributor tags if relevant.
- Optionally update the Test Plan with a short note about the environment used for manual testing (e.g.,
Tested in: EasyAuth-enabled Azure environment with expired session) if you completed that test.
Please update only if you want to include contributor credits or the explicit test environment note. Otherwise this PR looks ready to merge. Thanks for the clear description and tests!
Last updated: Tue, 17 Feb 2026 20:18:32 GMT
|
📊 Coverage check completed. See workflow run for details. |
|
📊 Coverage check completed. See workflow run for details. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the iframe-app’s useAgentCard hook to better handle Azure App Service EasyAuth scenarios where unauthenticated requests can result in a 302 redirect (often surfacing as an opaque redirect / status 0 in the browser), and to funnel those cases through the existing onUnauthorized flow.
Changes:
- Adds a shared
handleUnauthorizedhelper to centralizeonUnauthorizedinvocation + error throwing. - Forces
fetchto useredirect: 'manual'and treats opaque redirects /status === 0as unauthorized. - Treats
fetchrejection (e.g., network/CORS failures) as unauthorized.
…check, update tests
|
📊 Coverage check completed. See workflow run for details. |
|
📊 Coverage check completed. See workflow run for details. |
…trotrejo/iframeExcludeURls
📊 Coverage Check🎉 All changed files have adequate test coverage! |
takyyon
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit Type
Risk Level
What & Why
When Azure EasyAuth is enabled and the user's session expires, the server returns a 302 redirect to the login page instead of a 401. Because the
fetchAPI follows redirects by default and the login page is on a different origin, this results in a CORS error (opaque redirect /TypeError: Failed to fetch) rather than a meaningful HTTP status code. TheuseAgentCardhook did not handle this scenario, causing it to surface a generic network error instead of triggering theonUnauthorizedcallback.Additionally, authentication detection relied on comparing
response.statusText === 'Unauthorized', which is fragile and does not cover 403 Forbidden responses.Changes
fetch()call in a try/catch block so thatTypeError: Failed to fetch(caused by EasyAuth 302 redirects or CORS blocks) triggers theonUnauthorizedcallback and throws anUnauthorizederror.response.statusText === 'Unauthorized'check withresponse.status === 401 || response.status === 403for robust authentication failure detection.handleUnauthorizedhelper: Consolidated the duplicated unauthorized handling logic (callingonUnauthorizedcallback + throwing error) into a reusablehandleUnauthorizedasync function.Failed to fetch agent card: 500 Internal Server Error).onUnauthorizedcallback. Updated existing test mocks to includestatusproperty.Impact of Change
onUnauthorizedcallback now also fires on network/CORS errors and 403 responses.useAgentCardhook.Test Plan
Contributors
Screenshots/Videos