Skip to content

fix: Use try-catch to handle winget uninstall errors#75

Merged
hustcer merged 2 commits intomainfrom
develop
Feb 4, 2026
Merged

fix: Use try-catch to handle winget uninstall errors#75
hustcer merged 2 commits intomainfrom
develop

Conversation

@hustcer
Copy link
Contributor

@hustcer hustcer commented Feb 4, 2026

The winget uninstall nushell | complete pattern fails with exit code -1978335212 (APPINSTALLER_CLI_ERROR_NO_APPLICATIONS_FOUND) when nushell is not installed. This change uses try-catch to gracefully handle the error case.

The `winget uninstall nushell | complete` pattern fails with exit code
-1978335212 (APPINSTALLER_CLI_ERROR_NO_APPLICATIONS_FOUND) when nushell
is not installed. This change uses try-catch to gracefully handle the
error case.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Script Analysis

  • Key observations:
    • Changed error handling from complete to try/catch for winget uninstall operations
    • Maintains consistent pattern across multiple test functions
    • Still relies on external commands (winget, msiexec) for core functionality
    • No changes to data handling or pipeline structures

Security Review

  • Vulnerability findings:
    • ❗ No input validation for $MSI_PKG variable (potential path injection risk)
    • ⚠️ Silent error swallowing in catch blocks could mask important failures
    • External commands (winget, msiexec) executed without explicit path validation

Optimization Suggestions

  • Performance improvements:
    • Consider adding --ignore-errors flag to winget instead of try/catch for cleaner error handling
    • Could potentially batch uninstall operations if they're repeated in test sequence
    • Add parallel execution markers for independent test cases

Overall Quality: 3

checklist:
  - Compatibility: ["Nu 0.100+ compatible", "Windows-specific commands", "No plugin dependencies"]
  - Security: ["No input sanitization", "Silent error handling", "External command risks"]
  - Reliability: ["Error suppression", "No null handling", "No type validation"]
  - Performance: ["No lazy evaluation", "No batch processing", "No stream handling"]

The GitHub API returns 403 when rate limited. This change adds
authentication headers using GITHUB_TOKEN when available to avoid
hitting the rate limit.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@hustcer hustcer merged commit 42f14ea into main Feb 4, 2026
73 checks passed
@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Script Analysis

  • Added GitHub API authentication support via GITHUB_TOKEN environment variable
  • Improved error handling for winget uninstall commands using try/catch
  • Maintained consistent HTTP request pattern across multiple files
  • Kept existing pipeline logic while adding authentication layer

Security Review

  • ✅ Properly checks for existence of GITHUB_TOKEN before using it
  • ✅ Uses secure string interpolation for Bearer token
  • ⚠️ Consider adding error handling for failed HTTP requests with auth
  • ⚠️ Winget commands still run without explicit error checking of results

Optimization Suggestions

  • 🔄 Consider caching GitHub API responses to reduce rate limit hits
  • 🔄 Could consolidate HTTP request logic into a shared module function
  • ⏱️ Add parallel execution for independent winget operations where possible
  • 📦 Consider using Nu's built-in error handling more consistently (e.g., do -i)

Overall Quality: 4

checklist:
  - Compatibility: ["Nu 0.100+", "Windows-specific", "No plugin dependencies"]
  - Security: ["Token handling secure", "No command injection risks", "Minimal env exposure"]
  - Reliability: ["Improved error handling", "Null checks present", "Type safety maintained"]
  - Performance: ["HTTP optimization possible", "Parallelization opportunities", "No major bottlenecks"]

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.

1 participant