-
-
Notifications
You must be signed in to change notification settings - Fork 945
fix: propagate errors from backend installs #6236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4e697bc
fix: propagate errors from backend installs
jdx 8fbaa70
refactor: always return InstallFailed error for consistency
jdx e91896a
Merge branch 'main' into err-fix
jdx 1df3723
fix: perf issue with poetry and tasks
jdx 54882bf
fix(backend): correct error wrapping with WrapErr trait
jdx 50e7ae5
refactor(backend): simplify error message by removing redundant backe…
jdx 2aceaec
fix(errors): improve error messages and test patterns
jdx 1e61157
fix(errors): remove double wrapping of installation errors
jdx 7710019
refactor(test): rewrite test_error_display to use snapshot-style mult…
jdx 1329c66
refactor(test): simplify test_error_display by removing all normaliza…
jdx 6701a59
fix(test): rewrite test_error_display to properly check multiline output
jdx f31dad0
fix: improve NO_COLOR and error display handling
jdx 85e0d86
fix: use color-eyre Theme configuration for NO_COLOR support
jdx 67994ff
fix: create local assert_fail function for error display test
jdx 4f39bba
feat(test): broaden error display test assertions for comprehensive v…
jdx 66d7683
refactor: simplify MISE_FRIENDLY_ERROR to return bool with embedded d…
jdx 5e0ad67
Merge branch 'origin/main' into err-fix
jdx 8effb91
[autofix.ci] apply automated fixes
autofix-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Test comprehensive error display | ||
| # This test validates that error messages are properly formatted and structured | ||
|
|
||
| # Try to disable colors | ||
| export NO_COLOR=1 | ||
|
|
||
| # Local assert_fail function that doesn't force MISE_FRIENDLY_ERROR | ||
| local_assert_fail() { | ||
| local cmd="$1" | ||
| local expected="${2:-}" | ||
| local status=0 | ||
| local actual | ||
|
|
||
| debug "$ $cmd" | ||
| actual=$(RUST_BACKTRACE=0 bash -c "$cmd 2>&1") || status=$? | ||
|
|
||
| if [[ $status -eq 0 ]]; then | ||
| fail "[$cmd] command succeeded but was expected to fail" | ||
| fi | ||
|
|
||
| if [[ -z $expected ]]; then | ||
| ok "[$cmd] expected failure" | ||
| elif [[ $actual == *"$expected"* ]]; then | ||
| ok "[$cmd] output contains expected text" | ||
| else | ||
| fail "[$cmd] expected '$expected' but got '$actual'" | ||
| fi | ||
| } | ||
|
|
||
| echo "Testing error message formatting..." | ||
|
|
||
| # ============================================================================= | ||
| # PART 1: Testing with FRIENDLY errors (simplified output) | ||
| # ============================================================================= | ||
| echo "" | ||
| echo "PART 1: Testing FRIENDLY error format (MISE_FRIENDLY_ERROR=1)" | ||
| echo "============================================================" | ||
| export MISE_FRIENDLY_ERROR=1 | ||
|
|
||
| # Test 1: Invalid tool version error | ||
| echo "Test 1: Invalid tool version" | ||
| local_assert_fail "mise install core:node@invalid-version" \ | ||
| "mise ERROR Failed to install core:node@invalid-version: | ||
| 0: HTTP status client error (404 Not Found) for url (https://nodejs.org/dist/vinvalid-version/node-vinvalid-version.tar.gz)" | ||
|
|
||
| # Test 2: Backend error (cargo) | ||
| echo "Test 2: Cargo backend error" | ||
| local_assert_fail "mise install cargo:nonexistent-crate-12345@1.0.0" \ | ||
| "mise ERROR Failed to install cargo:nonexistent-crate-12345@1.0.0: | ||
| 0: HTTP status client error (404 Not Found) for url (https://index.crates.io/no/ne/nonexistent-crate-12345)" | ||
|
|
||
| # Test 3: GitHub repository not found | ||
| echo "Test 3: GitHub repository not found" | ||
| local_assert_fail "mise install github:nonexistent-org/nonexistent-repo@latest" \ | ||
| "mise ERROR Failed to install github:nonexistent-org/nonexistent-repo@latest: | ||
| 0: HTTP status client error (404 Not Found) for url (https://api.github.com/repos/nonexistent-org/nonexistent-repo/releases)" | ||
|
|
||
| # Test 4: Plugin not found | ||
| echo "Test 4: Plugin not found" | ||
| local_assert_fail "mise install nonexistent-tool@1.0.0" \ | ||
| "mise ERROR nonexistent-tool not found in mise tool registry" | ||
|
|
||
| # Test 5: Multiple tool failures (could be single or multiple depending on timing) | ||
| echo "Test 5: Multiple tool failures" | ||
| local_assert_fail "mise install tiny@999.999.999 jq@999.999.999" \ | ||
| "mise ERROR Failed to install aqua:jqlang/jq@999.999.999: | ||
| 0: HTTP status client error (404 Not Found) for url (https://api.github.com/repos/jqlang/jq/releases/tags/jq-999.999.999)" | ||
|
|
||
| # ============================================================================= | ||
| # PART 2: Testing with DETAILED errors (full error chains) | ||
| # ============================================================================= | ||
| echo "" | ||
| echo "PART 2: Testing DETAILED error format (MISE_FRIENDLY_ERROR=0)" | ||
| echo "============================================================" | ||
| export MISE_FRIENDLY_ERROR=0 | ||
|
|
||
| # Test 1: Invalid tool version error - check for the numbered error format with more context | ||
| echo "Test 1: Invalid tool version" | ||
| local_assert_fail "mise install core:node@invalid-version" \ | ||
| "Error: | ||
| 0: Failed to install core:node@invalid-version: | ||
| 0: HTTP status client error (404 Not Found) for url (https://nodejs.org/dist/vinvalid-version/node-vinvalid-version.tar.gz)" | ||
|
|
||
| # Test 2: Backend error (cargo) - check for numbered error format with more context | ||
| echo "Test 2: Cargo backend error" | ||
| local_assert_fail "mise install cargo:nonexistent-crate-12345@1.0.0" \ | ||
| "Error: | ||
| 0: Failed to install cargo:nonexistent-crate-12345@1.0.0: | ||
| 0: HTTP status client error (404 Not Found) for url (https://index.crates.io/no/ne/nonexistent-crate-12345)" | ||
|
|
||
| # Test 3: GitHub repository not found - check for numbered error format with more context | ||
| echo "Test 3: GitHub repository not found" | ||
| local_assert_fail "mise install github:nonexistent-org/nonexistent-repo@latest" \ | ||
| "Error: | ||
| 0: Failed to install github:nonexistent-org/nonexistent-repo@latest: | ||
| 0: HTTP status client error (404 Not Found) for url (https://api.github.com/repos/nonexistent-org/nonexistent-repo/releases)" | ||
|
|
||
| # Test 4: Multiple tool failures - check for numbered error format | ||
| echo "Test 4: Multiple tool failures" | ||
| local_assert_fail "mise install tiny@999.999.999 jq@999.999.999" \ | ||
| "Error: | ||
| 0: Failed to install aqua:jqlang/jq@999.999.999: | ||
| 0: HTTP status client error (404 Not Found) for url (https://api.github.com/repos/jqlang/jq/releases/tags/jq-999.999.999)" | ||
|
|
||
| # Test 5: Error with backtrace enabled - check for proper backtrace format | ||
| echo "Test 5: Error with backtrace" | ||
| local_assert_fail "RUST_BACKTRACE=1 mise install core:node@invalid-version" \ | ||
| "Error: | ||
| 0: Failed to install core:node@invalid-version: HTTP status client error (404 Not Found) for url (https://nodejs.org/dist/vinvalid-version/node-vinvalid-version.tar.gz)" | ||
|
|
||
| # Test 6: Invalid configuration (treated as version strings) | ||
| echo "Test 6: Invalid configuration" | ||
| cat >test_invalid_config.toml <<EOF | ||
| [tools] | ||
| node = "this is not valid" | ||
| python = ["also", "not", "valid"] | ||
| EOF | ||
|
|
||
| local_assert_fail "MISE_CONFIG_FILE=test_invalid_config.toml mise install" \ | ||
| "Error: | ||
| 0: Failed to install tools: core:python@also, core:python@not, core:python@valid, core:node@this is not valid" | ||
| rm -f test_invalid_config.toml | ||
|
|
||
| echo "" | ||
| echo "All error display tests passed!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.