fix: handle NotAuthenticatedError in error boundary gracefully#2086
Open
jonathanlab wants to merge 1 commit intomainfrom
Open
fix: handle NotAuthenticatedError in error boundary gracefully#2086jonathanlab wants to merge 1 commit intomainfrom
jonathanlab wants to merge 1 commit intomainfrom
Conversation
…th state change Generated-By: PostHog Code Task-Id: dd3912cb-28de-4bd9-a74b-daef7ae8a22c
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/components/ErrorBoundary.test.tsx:136-162
**Prefer parameterised tests for `isNotAuthenticatedError`**
The three `it` blocks below cover five distinct input/expectation pairs and would be cleaner as a single `it.each` table. The current structure also buries the three `false` assertions inside one test body, making it easy to miss a case. Using `it.each` maps each input to its expected result in one place and is the team's stated preference for tests like these.
Reviews (1): Last reviewed commit: "feat: suppress NotAuthenticatedError in ..." | Re-trigger Greptile |
Comment on lines
+136
to
+162
| rerender( | ||
| <Boundary> | ||
| <Thrower error={null} /> | ||
| </Boundary>, | ||
| ); | ||
| await user.click(screen.getByRole("button", { name: /try again/i })); | ||
| expect(screen.getByText("ok")).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe("isNotAuthenticatedError", () => { | ||
| it("matches NotAuthenticatedError instances", () => { | ||
| expect(isNotAuthenticatedError(new NotAuthenticatedError())).toBe(true); | ||
| }); | ||
|
|
||
| it("matches plain objects with the same name (e.g. tRPC-serialized errors)", () => { | ||
| expect(isNotAuthenticatedError({ name: "NotAuthenticatedError" })).toBe( | ||
| true, | ||
| ); | ||
| }); | ||
|
|
||
| it("does not match unrelated errors", () => { | ||
| expect(isNotAuthenticatedError(new Error("Not authenticated"))).toBe(false); | ||
| expect(isNotAuthenticatedError(null)).toBe(false); | ||
| expect(isNotAuthenticatedError("Not authenticated")).toBe(false); | ||
| }); | ||
| }); |
Contributor
There was a problem hiding this comment.
Prefer parameterised tests for
isNotAuthenticatedError
The three it blocks below cover five distinct input/expectation pairs and would be cleaner as a single it.each table. The current structure also buries the three false assertions inside one test body, making it easy to miss a case. Using it.each maps each input to its expected result in one place and is the team's stated preference for tests like these.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/components/ErrorBoundary.test.tsx
Line: 136-162
Comment:
**Prefer parameterised tests for `isNotAuthenticatedError`**
The three `it` blocks below cover five distinct input/expectation pairs and would be cleaner as a single `it.each` table. The current structure also buries the three `false` assertions inside one test body, making it easy to miss a case. Using `it.each` maps each input to its expected result in one place and is the team's stated preference for tests like these.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
adboio
approved these changes
May 7, 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.
Extracted "Not authenticated" errors into a dedicated
NotAuthenticatedErrorclass and updated the error boundary to suppress these errors instead of displaying them, allowing the auth state to naturally resolve to show the authentication screen.Created with PostHog Code