Skip to content

Fix type safety and error handling in Azure Login action#21

Draft
Copilot wants to merge 2 commits intocopilot/fix-login-issuefrom
copilot/update-login-functionality-one-more-time
Draft

Fix type safety and error handling in Azure Login action#21
Copilot wants to merge 2 commits intocopilot/fix-login-issuefrom
copilot/update-login-functionality-one-more-time

Conversation

Copy link

Copilot AI commented Feb 4, 2026

Problem

The codebase had unsafe error handling that could crash at runtime and weak TypeScript typing that defeated compile-time safety.

Changes

Error handling

  • Add type guards before accessing error.stack and error.message properties
  • Prevents runtime crashes when non-Error objects are thrown
// Before
catch (error) {
    core.setFailed(`Login failed with ${error}.`);
    core.debug(error.stack);  // Unsafe - crashes if error isn't an Error
}

// After  
catch (error) {
    const errorMessage = error instanceof Error ? error.message : String(error);
    core.setFailed(`Login failed with ${errorMessage}.`);
    if (error instanceof Error && error.stack) {
        core.debug(error.stack);
    }
}

Type safety

  • Replace any types with ExecOptions interface from @actions/exec
  • Affects: AzureCliLogin.executeAzCliCommand(), AzPSUtils.runPSScript()
  • Enables proper IDE autocomplete and compile-time validation

Code quality

  • Replace loose equality (==) with strict equality (===)
  • Applies to: preCleanup environment variable check in main.ts
Original prompt

Reference: db74ff4


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Fix unsafe error handling by checking error type before accessing properties
- Replace loose equality (==) with strict equality (===) for type safety
- Remove all 'any' types and use proper TypeScript ExecOptions interface
- Improve error messages to show only error message, not full object toString
- Add proper type checking before accessing error.stack to prevent runtime errors

These changes enhance the reliability and maintainability of the codebase while maintaining backward compatibility.

Co-authored-by: Jury1981 <210622247+Jury1981@users.noreply.github.com>
Copilot AI changed the title [WIP] Update login functionality for better user experience Fix type safety and error handling in Azure Login action Feb 4, 2026
Copilot AI requested a review from Jury1981 February 4, 2026 15:21
@github-actions github-actions bot added the Stale label Feb 18, 2026
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

This PR is idle because it has been open for 14 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants