pyupio/safety

AttributeError: 'bool' object has no attribute 'get'

xorr-sm opened this issue · 4 comments

  • safety version: 3.2.0
  • Python version: 3.10
  • Operating System: Ubuntu 22.04.3

Description

Ran safety via nox in parallel build in build server. Expected successful safety run without unhandled exceptions.

What I Did

Ran safety in a parallel build via nox. Got JSONDecodeError trying to get the cached database. because of AttributeError: 'bool' object has no attribute 'get'.

Command:
safety --key <our safety key> --stage production --debug true scan --detailed-output --policy-file <our safety file location>/.safety-policy.yml

Traceback: 
 safety.safety => Getting the database from cache at 1718329340.347285, cache setting: 0
 safety.safety => Getting the database from cache at 1718329344.2699468, cache setting: 0
 safety.safety => Getting the database from cache at 1718329344.2699468, cache setting: 0

 safety.safety => JSONDecodeError trying to get the cached database.
 safety.cli_util => Unexpected Exception happened: 'bool' object has no attribute 'get'

Traceback (most recent call last):
  File "<jenkins internal filepath>/.nox/lib/python3.10/site-packages/safety/cli_util.py", line 578, in inner
    return func(ctx, *args, **kwargs)
  File "<jenkins internal filepath>/.nox/lib/python3.10/site-packages/safety/scan/decorators.py", line 327, in inner
    return func(ctx, *args, **kwargs)
  File "<jenkins internal filepath>/.nox/lib/python3.10/site-packages/safety/scan/decorators.py", line 178, in inner
    result = func(ctx, target=target, output=output, *args, **kwargs)
  File "<jenkins internal filepath>/.nox/lib/python3.10/site-packages/safety/scan/command.py", line 291, in scan
    for path, analyzed_file in process_files(paths=file_paths,
  File "<jenkins internal filepath>/.nox/lib/python3.10/site-packages/safety/scan/main.py", line 162, in process_files
    inspectable_file.inspect(config=config)
  File "<jenkins internal filepath>/.nox/lib/python3.10/site-packages/safety/scan/ecosystems/python/main.py", line 289, in inspect
    self.__find_dependency_vulnerabilities__(dependencies=dependencies,
  File "<jenkins internal filepath>/.nox/lib/python3.10/site-packages/safety/scan/ecosystems/python/main.py", line 197, in __find_dependency_vulnerabilities__
    vulnerable_packages = frozenset(db.get('vulnerable_packages', []))

AttributeError: 'bool' object has no attribute 'get'
Unhandled exception happened: 'bool' object has no attribute 'get'

This has been addressed here: #544

Thanks, @xorr-sm, for this issue report. The fix is present in the 3.2.4 release; to close this issue, we would like you to confirm that the bug is solved when using the latest version.

We have integrated version 3.2.4 into our system and we haven't see any failing builds due to this error. This has resolved the issue. Thanks.