Skip to content

Improve error handling in Hyperskill authorization flow #9

@meanmail

Description

@meanmail

Overview

The authorization flow has insufficient error handling and doesn't properly handle edge cases like dialog cancellation or network failures.

Location

File: intellij-plugin/hs-core/src/org/hyperskill/academy/learning/stepik/hyperskill/HyperskillRestService.kt
Functions: withUserIdCheck (lines 102-146), askToReLogin (line 188+)

Problems

  1. askToReLogin makes an API call with getUser(userId) that can fail, but error handling is minimal
  2. Line 194: getInEdt is used without proper exception handling - if user closes dialog unexpectedly, state is inconsistent
  3. No timeout handling for API calls
  4. If re-login is initiated (line 140), the original action is never retried if authorization fails

What needs to be fixed

  • Add proper timeout and retry logic for getUser API call
  • Handle dialog cancellation and window close events properly
  • Add logging for authorization flow steps (useful for debugging user issues)
  • Ensure doAuthorize callback is properly invoked even if re-login fails
  • Add a state machine or explicit states for authorization flow to prevent inconsistencies

Tests understanding of

  • REST API error handling patterns
  • Dialog state management
  • EDT operations with dialogs (getInEdt)
  • Callback patterns and error propagation
  • User interaction flow design
  • Network resilience and timeout handling

Validation

  • Simulate network failures (disconnect during authorization)
  • Cancel dialog at various stages
  • Test with invalid credentials
  • Ensure consistent state and proper error messages
  • Verify original action is retried after successful re-login

Estimated time

4-5 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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