Skip to content

[Bug] OAuth error response rendered as raw JSON in UI — exposes internal API error codes to users #676

Description

@RUKAYAT-CODER

Overview

During login, src/hooks/useAuth.tsx passes the raw axios error response body to UI error state. For OAuth token exchange failures, the backend returns JSON like {"error":"invalid_grant","error_description":"Token expired"}. This raw JSON string is rendered directly in the UI label, exposing technical OAuth codes and internal API error descriptions to users.

Specifications

Features:

  • Auth error messages mapped to user-friendly strings in src/utils/authErrorMessages.ts
  • invalid_grant maps to message about expired session
  • access_denied maps to credentials error message
  • Raw error details logged to appLogger.error, never shown in UI

Tasks:

  • Create src/utils/authErrorMessages.ts mapping OAuth error codes to user messages
  • In useAuth.tsx error handler, parse error.response?.data?.error and look up user message
  • Fall back to generic message for unknown codes
  • Log raw response to appLogger.error
  • Add unit tests for each mapped error code

Impacted Files:

  • src/hooks/useAuth.tsx
  • src/utils/authErrorMessages.ts (create)

Acceptance Criteria

  • User never sees raw JSON or OAuth error codes in UI
  • Common OAuth error codes mapped to friendly messages
  • Unknown codes produce generic fallback message
  • Full error details still appear in appLogger.error for debugging

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't workingsecuritySecurity vulnerability or concern

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions