Fix Taskfile not found error handling#2582
Open
semihbkgr wants to merge 1 commit intogo-task:mainfrom
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2581
When running
taskin a directory without a Taskfile, the error message was showing an empty path (task: No Taskfile found at "") and missing the helpful--initsuggestion. This was caused by conflicting error handling whereNewFileNode()was already wrappingos.ErrNotExistasTaskfileNotFoundError, butgetRootNode()was checking foros.IsNotExist(err)which failed on the wrapped error.Solution
Moved
--initsuggestion logic from error type to caller: Removed theAskInitfield fromTaskfileNotFoundErrorand moved the suggestion logic togetRootNode()insetup.go. This separates the concern of "what happened" (file not found) from "what to suggest to the user" (run --init), and ensures the suggestion only appears when appropriate (i.e., when running plaintaskwithout-tor-dflags, since--initignores those flags).Fixed URI construction: Added
fsext.GetSearchPath()helper to properly determine the absolute path being searched. This ensuresTaskfileNotFoundError.URIalways contains a meaningful path instead of an empty string.Simplified error handling: Changed
getRootNode()to useerrors.As()to properly detectTaskfileNotFoundErrorand wrap it with the--initsuggestion when appropriate, instead of trying to re-wrapos.ErrNotExist.Result
--initsuggestion appears only when runningtaskwithout flags