Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

crash when supplying YAML file to --from-json #3596

Closed
armijnhemel opened this issue Nov 17, 2023 · 2 comments
Closed

crash when supplying YAML file to --from-json #3596

armijnhemel opened this issue Nov 17, 2023 · 2 comments
Labels

Comments

@armijnhemel
Copy link
Contributor

Description

Related to #3595

When supplying a YAML file to --from-json there is a crash.

How To Reproduce

$ ./scancode --from-json /tmp/scancode.yaml --yaml /tmp/scancode2.yaml
Setup plugins...
Collect file inventory...
Removing temporary files...done.
Usage: scancode [OPTIONS] <OUTPUT FORMAT OPTION(s)> <input>...
Try the 'scancode --help' option for help on options and arguments.

Error: Invalid value: ERROR: failed to collect codebase at: '/tmp/scancode.yaml'
Traceback (most recent call last):
  File "/home/armijn/git/scancode-toolkit/src/scancode/cli.py", line 844, in run_scan
    codebase = codebase_class(
  File "/home/armijn/git/scancode-toolkit/venv/lib/python3.10/site-packages/commoncode/resource.py", line 1676, in __init__
    scan_data = self._get_scan_data(location)
  File "/home/armijn/git/scancode-toolkit/venv/lib/python3.10/site-packages/commoncode/resource.py", line 1736, in _get_scan_data
    return self._get_scan_data_helper(location)
  File "/home/armijn/git/scancode-toolkit/venv/lib/python3.10/site-packages/commoncode/resource.py", line 1690, in _get_scan_data_helper
    scan_data = json.load(f)
  File "/usr/lib64/python3.10/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib64/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

System configuration

For bug reports, it really helps us to know:

  • What OS are you running on? (Windows/MacOS/Linux)
  • What version of scancode-toolkit was used to generate the scan file?
  • What installation method was used to install/run scancode? (pip/source download/other)
pombredanne added a commit that referenced this issue Nov 24, 2023
This is to ensure that the input are regular files or directories
and that the output are writable files if they pre-exist.

This is a fix for closely related issues:

Referenced-by: #3588
Referenced-by: #3589
Referenced-by: #3590
Referenced-by: #3591
Referenced-by: #3592
Referenced-by: #3593
Referenced-by: #3594
Referenced-by: #3595
Referenced-by: #3596

Reported-by: Armijn Hemel @armijnhemel
Reported-by: Till Jaeger @LeChasseur
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
AyanSinhaMahapatra added a commit that referenced this issue Mar 18, 2024
@armijnhemel
Copy link
Contributor Author

This seems to work properly now.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants