-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Improved error message for version restrictions #633
base: master
Are you sure you want to change the base?
Conversation
Having this additional information is certainly helpful. The initial error message could already contain some diagnostic information to help the user directly, instead of just guiding to run again with We know which shard failed to install, so we could show some basic information such as available versions. Maybe filter/highlight ones that are similar to the missing version, to help against typos? I expect the verbose tag output with |
100% agree. I frankly don't know why my past self thought that |
I talked to my past self, and I realized that the Now it produces the following output:
There's currently no filtering, so for shards with a large list of tags it will print everything. Note also the following: this output doesn't help to the problem in #521:
I guess we need to filter the version before even reaching molinillo: if a requirement starts with |
I like moving in this direction 👍 It might still be a bit much to always print all tags, though. An overload of information is probably not very helpful. Maybe a first step could be to filter only tags that are valid versions. And then maybe some |
Yes, I mention as a problem that there's no filtering. But, as said, this doesn't solve the original problem, and the output is |
A bit hackish to say the least, but at least it produces a better output:
I'm certain this won't cover all possible scenarios, but at least it will improve the situation. |
src/commands/command.cr
Outdated
Log.error { e.message } | ||
Log.error { log_available_tags(e.conflicts) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: This should probably be a single error message. The conflict information is just context for the version conflict error, not itself another error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OTOH if some workflow expects the error output as before, changing that might break it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If something depends on the full exact text of the error message, it should be expected to break.
We cannot possibly guarantee stability on that.
src/commands/command.cr
Outdated
if req.is_a?(Version) || (req.is_a?(VersionReq) && req.patterns.size == 1 && req.patterns[0] !~ /^(<|>|=)/) | ||
req = "v" + req.to_s | ||
found = Levenshtein.find(req, tags, 6) | ||
"For #{k} the closest available tag to #{req} is: #{found}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: This branch is about version restrictions. We should not confuse that with tags.
It's an implementation detail that versions are represented as tags in the version control systems.
So the base set should be available_releases
instead of available_tags
. For a version restriction we don't care about all the tags, only the versions.
Also, I believe we need to explicitly handle the case that no versions are available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean simply replacing tags for release in messages and function names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main change would be to use resolver.available_releases
instead of resolve.available_tags
as source of available items for this branch. And then adapt the wording as well, of course.
I can make a patch against your branch to demonstrate what I mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that won't work for what we want to do here. If you filter already the tags, then you don't get information to display the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll think of an alternative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use releases but also show tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the top level distinction must be based on the type of restriction in order to produce an appropriate error message. For example, if the restriction is branch: foo
there's no point talking about releases.
case req
when Version
# fetch available releases
# check for close matches
# check for similar refs that are not versions
when VersionReq
# fetch available releases
# check for close matches relative to the restriction
# check for similar refs that are not versions
when GitBranchRef, HgBranchRef, FossilBranchRef
# fetch available branches
# check for close matches
# check for similar refs that are not branches
when GitTagRef, HgTagRef, FossilTagRef
# fetch available tags
# check for close matches
# check for similar refs that are not tags
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm... this is harder than thought:
- Version is used in very specific cases, and I don't think a levenshtein diff will be useful
- VersionReq has the "just this version" case which follows the patter of Version above. This is the only useful case.
- Any other VersionReq is hard to comply to "close match". What is close match of ">0.3.0, <0.3.0"?
- A failing branch fails at checkin, not at resolving, so won't be part of this case.
- Tags never fail??
So I'm tempted to leave it as is for now.
I wasn't considering properly the case when the failure is a conflict with different shards. I guess there we need to resort to the original error message, that is, filter the case when there's only one conflict. |
I'm having a hard time wrapping my head around what's the changes are doing. And especially why things are implemented the way they are. But it's inherently quite a challenge to be aware of all the invariants in the code. For example, keep track what are the conditions that lead to each of the variations of error messages. @beta-ziliani Let me know if you want me to take this. |
This PR introduces two minor changes as a palliative to #521 :
Output on a failing run when the release doesn't exist:
Output on a failing run when the release is wrongly set (it has a
v
):Output on a failing run when the tag is not a release: