Skip to content
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

[v2-engine errors] Sort suggestions for typo'd targets. dedup errors w/o trace #5413

Conversation

baroquebobcat
Copy link
Contributor

Problem

When there are a large number of suggestions, the lack of alphanumeric sorting is frustrating. #4788

Solution

Sort the suggestions. Additionally, I noticed that because of where this happens, there may be multiple copies of the error message that show up. I changed the default behavior to dedup common errors.

Result

./pants list 3rdparty/python:rutaba --no-print-exception-stacktrace
Exception caught: (<class 'pants.build_graph.address_lookup_error.AddressLookupError'>)

Exception message: "rutaba" was not found in namespace "3rdparty/python". Did you mean one of:
  :Markdown
  :Pygments
  :ansicolors

Instead of

Exception caught: (<class 'pants.build_graph.address_lookup_error.AddressLookupError'>)

Exception message: Build graph construction failed: ExecutionError Multiple exceptions encountered:
  ResolveError: "rutaba" was not found in namespace "3rdparty/python". Did you mean one of:
  :psutil
  :isort
  :pywatchman
  :pytest-cov
...
  :scandir
  :setuptools
  ResolveError: "rutaba" was not found in namespace "3rdparty/python". Did you mean one of:
  :psutil
  :isort
  :pywatchman
  :pytest-cov
  :setproctitle
...
  :scandir
  :setuptools

Copy link
Contributor

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! :) Thanks!

raise throw_root_states[0].exc
else:
raise ExecutionError('Multiple exceptions encountered:\n {}'
.format('\n '.join('{}: {}'.format(type(t.exc).__name__, str(t.exc))
for t in throw_root_states)))
.format('\n '.join('{}: {}'.format(type(t).__name__, str(t))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This makes the order of exception reports non-deterministic. That's probably fine (and I expect the engine probably reports them in a non-deterministic order, too), but it may be worth preserving their reported order. Probably not, though :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. I feel like what we need is to have a better approach to reporting errors in general, but I'm still not sure what that looks like. That's why there's a TODO above and #3912. The specific issues in #3912 are better, but not yet good.

The errors appear to be deterministic when you look at them with the full trace, so at least theres that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you just throw in a sorted(unique_exceptions) here, maybe?

raise throw_root_states[0].exc
else:
raise ExecutionError('Multiple exceptions encountered:\n {}'
.format('\n '.join('{}: {}'.format(type(t.exc).__name__, str(t.exc))
for t in throw_root_states)))
.format('\n '.join('{}: {}'.format(type(t).__name__, str(t))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you just throw in a sorted(unique_exceptions) here, maybe?

@baroquebobcat baroquebobcat merged commit bfe927d into pantsbuild:master Feb 1, 2018
@baroquebobcat
Copy link
Contributor Author

@kwlzn I probably could. Missed your comment before I merged though.

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.

4 participants