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

Report file where an error occurred during CLI operations #208

Open
cholmes opened this issue Oct 20, 2021 · 1 comment
Open

Report file where an error occurred during CLI operations #208

cholmes opened this issue Oct 20, 2021 · 1 comment
Labels
cli Command line interface enhancement New feature or request

Comments

@cholmes
Copy link
Contributor

cholmes commented Oct 20, 2021

Is your feature request related to a problem? Please describe.

Often I run an operation that operates on a whole catalog - usually 'copy', sometimes 'validate' or 'merge' - and I'll get an error, that reports a problem, but I have no idea where it occurs. My latest is (I think) a missing license from a 'collection':

Traceback (most recent call last):
  File "/Users/cholmes/.local/bin/stac", line 8, in <module>
    sys.exit(run_cli())
  ...
  File "/Users/cholmes/.local/lib/python3.7/site-packages/pystac/stac_io.py", line 168, in stac_object_from_dict
    d, href=href, root=root, migrate=False, preserve_dict=preserve_dict
  File "/Users/cholmes/.local/lib/python3.7/site-packages/pystac/collection.py", line 589, in from_dict
    license = d.pop("license")
KeyError: 'license'

(realizing this particular error is probably worth an issue in its own right to better report what happens, but that's not actually why I'm putting in this issue).

The problem is that I think I only have one collection, which definitely has a license, so I have no idea how to try to find where STAC is failing. I suspect it's some errant link to some older file, maybe cached in some way. But it's impossible fo rme track down which of the 50 or so STAC files has the error. The best I can do is run it on smaller and smaller sub-catalogs to try to isolate it, which is painful, and still doesn't get me all the way to which file generated the error.

Describe the solution you'd like
I would like stac errors to show me the location of the file where the exception was raised. Bonus points if it shows me the line numbers.

Describe alternatives you've considered
#51 was a similar report, and resulted in the stac validate command, which was a step in the right direction. But it still misses reporting what file an error comes from.

@cholmes cholmes added the enhancement New feature or request label Oct 20, 2021
@cholmes
Copy link
Contributor Author

cholmes commented Oct 20, 2021

I did notice that stac validate does have some reporting of the file where an error is, so perhaps this is just a problem with this particular bug, instead of general. But I usually don't 'stac validate' before I do operations, perhaps we do just pre-emptively run 'validate' when someone is running a command that may not work unless it's a valid catalog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Command line interface enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants