Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix: distinguish definite reset internal failures

Josué07e3ea7e839f
diff --git a/profile-ui/app/components/__tests__/InvitationClient.recoveryContract.test.tsx b/profile-ui/app/components/__tests__/InvitationClient.recoveryContract.test.tsx
index d324ecde8..bd81db137 100644
--- a/profile-ui/app/components/__tests__/InvitationClient.recoveryContract.test.tsx
+++ b/profile-ui/app/components/__tests__/InvitationClient.recoveryContract.test.tsx
@@ -85,6 +85,7 @@ describe('R6 recovery outcome and identity fences', () => {
'unknown post-dispatch outcome',
new ProfileApiError(503, 'recovery_outcome_unknown', 'temporary service message'),
],
+ ['unclassified 500 failure', new ProfileApiError(500, 'upstream_failure', 'private detail')],
])('does not replay a reset after %s', async (_label, error) => {
mocks.setupInvitationPasswordWithToken.mockRejectedValueOnce(error)
renderReset()
@@ -109,6 +110,7 @@ describe('R6 recovery outcome and identity fences', () => {
'definite authority rejection',
new ProfileApiError(503, 'authority_unavailable', 'temporary authority message'),
],
+ ['definite internal failure', new ProfileApiError(500, 'internal_error', 'private detail')],
])('keeps a definite %s retryable rather than ambiguous', async (_label, error) => {
mocks.setupInvitationPasswordWithToken.mockRejectedValueOnce(error).mockResolvedValueOnce({
...passwordReset,
diff --git a/profile-ui/app/invitations/[token]/InvitationClient.tsx b/profile-ui/app/invitations/[token]/InvitationClient.tsx
index 81c541ec4..8b565bb9c 100644
--- a/profile-ui/app/invitations/[token]/InvitationClient.tsx
+++ b/profile-ui/app/invitations/[token]/InvitationClient.tsx
@@ -86,6 +86,7 @@ function isAmbiguousRecoveryOutcome(value: unknown): boolean {
if (value instanceof TypeError || value.name === 'SyntaxError') return true
if (!(value instanceof ProfileApiError)) return false
if (value.code === 'recovery_outcome_unknown') return true
+ if (value.status === 500 && value.code === 'internal_error') return false
if (value.code === 'authority_unavailable' || value.code === 'rate_limited') return false
if (value.status === 429) return false
return value.status >= 500
diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.json
index ba44f58b3..74f3b09a3 100644
--- a/profile-ui/package-lock.json
+++ b/profile-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.179",
+ "version": "0.1.180",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-profile-ui",
- "version": "0.1.179",
+ "version": "0.1.180",
"dependencies": {
"@clerum/desktop-app-links": "file:../packages/desktop-app-links",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/profile-ui/package.json b/profile-ui/package.json
index d8d8f21db..65d68d176 100644
--- a/profile-ui/package.json
+++ b/profile-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.179",
+ "version": "0.1.180",
"private": true,
"scripts": {
"dev": "next dev",
diff --git a/tests/e2e/playwright/package-lock.json b/tests/e2e/playwright/package-lock.json
index 8f1f75870..7d95c3c0e 100644
--- a/tests/e2e/playwright/package-lock.json
+++ b/tests/e2e/playwright/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-playwright-tests",
- "version": "0.1.80",
+ "version": "0.1.81",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-playwright-tests",
- "version": "0.1.80",
+ "version": "0.1.81",
"devDependencies": {
"@playwright/test": "^1.50.0",
"@types/node": "^22.0.0",
diff --git a/tests/e2e/playwright/package.json b/tests/e2e/playwright/package.json
index b1ef8f21d..48081cffb 100644
--- a/tests/e2e/playwright/package.json
+++ b/tests/e2e/playwright/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-playwright-tests",
- "version": "0.1.80",
+ "version": "0.1.81",
"private": true,
"description": "Playwright E2E tests for Control UI and Desktop App",
"scripts": {
diff --git a/tests/e2e/playwright/profile-ui-recovery-fixture.mjs b/tests/e2e/playwright/profile-ui-recovery-fixture.mjs
index 00e80be07..985a6c055 100644
--- a/tests/e2e/playwright/profile-ui-recovery-fixture.mjs
+++ b/tests/e2e/playwright/profile-ui-recovery-fixture.mjs
@@ -9,6 +9,7 @@ const repositoryRoot = path.resolve(fixtureDirectory, '../../..')
const profileUiRoot = path.join(repositoryRoot, 'profile-ui')
const externalRestRoot = path.join(repositoryRoot, 'external-rest-api')
const port = Number(process.env.PROFILE_UI_RECOVERY_PORT || 31873)
+const profileOrigin = `http://127.0.0.1:${port}`
const invitationToken = 'synthetic-reset-proof'
const syntheticServiceAuthorization = ['Bearer', 'synthetic-profile-recovery-service-token'].join(
' '
@@ -547,6 +548,8 @@ const apiServer = createServer(async (request, response) => {
rate_limited: [429, 'rate_limited'],
authority_unavailable: [503, 'authority_unavailable'],
recovery_outcome_unknown: [503, 'recovery_outcome_unknown'],
+ internal_error: [500, 'internal_error'],
+ unknown_500: [500, 'unclassified_failure'],
}
const scenario = body.password
.slice(contractPasswordPrefix.length)
@@ -586,7 +589,7 @@ const externalRestProcess = spawn(
EXTERNAL_REST_API_JWT_PUBLIC_KEY: publicKey
.export({ type: 'spki', format: 'pem' })
.toString(),
- EXTERNAL_REST_API_CORS_ORIGIN: 'http://127.0.0.1:31873',
+ EXTERNAL_REST_API_CORS_ORIGIN: profileOrigin,
},
stdio: ['pipe', 'pipe', 'inherit'],
}
diff --git a/tests/e2e/playwright/profile-ui-recovery/reset-session-hydration.spec.ts b/tests/e2e/playwright/profile-ui-recovery/reset-session-hydration.spec.ts
index 2d93cf6a1..657b6a759 100644
--- a/tests/e2e/playwright/profile-ui-recovery/reset-session-hydration.spec.ts
+++ b/tests/e2e/playwright/profile-ui-recovery/reset-session-hydration.spec.ts
@@ -30,6 +30,21 @@ const resetErrorCases = [
message:
'We could not confirm whether your password change completed. Try signing in with the new password. If that does not work, request a new reset link.',
},
+ {
+ errorCode: 'internal_error',
+ status: 500,
+ publicError: 'internal_error',
+ state: 'editable',
+ message: 'We could not update your password. Please try again.',
+ },
+ {
+ errorCode: 'unknown_500',
+ status: 503,
+ publicError: 'recovery_outcome_unknown',
+ state: 'ambiguous',
+ message:
+ 'We could not confirm whether your password change completed. Try signing in with the new password. If that does not work, request a new reset link.',
+ },
] as const
async function openRecovery(page: import('@playwright/test').Page) {
@@ -156,6 +171,9 @@ for (const failure of resetErrorCases) {
expect(resetResponse.status()).toBe(failure.status)
expect(resetResponse.headers()['set-cookie']).toBeUndefined()
+ if ('publicError' in failure) {
+ expect(await resetResponse.json()).toMatchObject({ error: failure.publicError })
+ }
await expect(page.getByText(failure.message, { exact: true })).toBeVisible()
await expect(
page.getByText('This recovery link is invalid or expired.', { exact: true })
@@ -169,5 +187,16 @@ for (const failure of resetErrorCases) {
expect((await page.context().cookies()).some(cookie => cookie.name === 'profile_session')).toBe(
false
)
+ if ('state' in failure && failure.state === 'editable') {
+ await expect(page.getByLabel('Password', { exact: true })).toBeVisible()
+ await expect(page.getByLabel('Confirm password')).toBeVisible()
+ await expect(page.getByRole('button', { name: 'Reset password' })).toBeEnabled()
+ }
+ if ('state' in failure && failure.state === 'ambiguous') {
+ await expect(page.getByLabel('Password', { exact: true })).toHaveCount(0)
+ await expect(page.getByRole('link', { name: 'Try signing in' })).toBeVisible()
+ await expect(page.getByRole('link', { name: 'Request a new recovery link' })).toBeVisible()
+ }
+ await expect(page.getByText(/unclassified_failure|private detail/)).toHaveCount(0)
})
}