{"record":{"id":"730b54608861c0d1","repo":"iOfficeAI/AionUi","slug":"reset-password-returned-no-new-password","errorCode":null,"errorMessage":"reset-password returned no new_password","messagePattern":"reset-password returned no new_password","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/desktop/src/process/utils/resetPasswordCLI.ts","lineNumber":60,"sourceCode":"export async function resetPasswordCLI(username: string): Promise<void> {\n  log.info(`Target user: ${username} (advisory — operates on system_default_user)`);\n  const port = (globalThis as typeof globalThis & { __backendPort?: number }).__backendPort;\n  if (!port) {\n    log.error('Backend did not start — cannot reset password');\n    process.exit(1);\n  }\n  try {\n    const res = await fetch(`http://127.0.0.1:${port}/api/webui/reset-password`, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json' },\n    });\n    if (!res.ok) {\n      const body = await res.text();\n      throw new Error(`reset-password failed (${res.status}): ${body}`);\n    }\n    const payload = (await res.json()) as { data?: { new_password?: string } };\n    const newPassword = payload.data?.new_password;\n    if (!newPassword) throw new Error('reset-password returned no new_password');\n    log.success('Password reset successfully.');\n    log.info('New password:');\n    log.highlight(newPassword);\n    log.info('');\n    log.warning('Please change this password after next login.');\n  } catch (error) {\n    log.error(error instanceof Error ? error.message : 'Password reset failed');\n    process.exit(1);\n  }\n}\n","sourceCodeStart":42,"sourceCodeEnd":71,"githubUrl":"https://github.com/iOfficeAI/AionUi/blob/711aa0550ee183ea495dc33e2c05c7943b70a60a/packages/desktop/src/process/utils/resetPasswordCLI.ts#L42-L71","documentation":"Thrown by the reset-password CLI when the backend returns 2xx for the reset request but the JSON payload lacks data.new_password, so no new credential can be printed to the user.","triggerScenarios":"Backend responds 200 with a payload where payload.data is missing or new_password is absent/renamed.","commonSituations":"Backend version drift changing the response schema, or an error object returned with HTTP 200.","solutions":["Log/inspect payload to see the actual response shape","Update the CLI to read the current field name used by the backend","Keep CLI and backend versions in lockstep; add a schema check on the backend side","If the backend wraps errors in 200 responses, fix the backend to use proper status codes"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"const payload = await res.json();\nif (!payload?.data?.new_password) { console.error('Unexpected payload:', payload); /* abort cleanly */ }","typeGuard":"function hasPasswordPayload(v: unknown): v is { data: { new_password: string } } {\n  return typeof (v as never)?.data?.new_password === 'string';\n}","tryCatchPattern":"catch (err) { console.error('reset-password schema mismatch:', err.message); process.exit(1); }","preventionTips":["Share API types between CLI and backend","Add response-schema smoke tests","Never print passwords in logs — only mismatch diagnostics"],"tags":["cli","password-reset","api-contract","schema"],"backgroundTag":"missing-response-field","analyzedSha":"711aa0550ee183ea495dc33e2c05c7943b70a60a","analyzedAt":"2026-08-28T07:56:06.558Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}