Closed msabramo closed 2 months ago
With #719, the output is:
$ detect-secrets-hook --baseline .secrets.baseline setup.py
[initialize] ERROR Error: Failed to load `FakeCustomPlugin` plugin:
[Errno 2] No such file or directory: './path/to/plugin/that/does/not/exist/plugin.py'
[initialize] ERROR This error can occur when using a baseline that references a custom plugin
with a path that does not exist.
[scan] ERROR Unable to load plugins!
which is much more useful for troubleshooting!
I'm submitting a ...
What is the current behavior? If you run something like
detect-secrets-hook --baseline .secrets.baseline setup.py
andsecrets.baseline
references a custom plugin that doesn't exist, you get aFileNotFoundError
with a long traceback, but unfortunately it doesn't tell you which file is missing.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
$ detect-secrets-hook --baseline .secrets.baseline setup.py Traceback (most recent call last): ... File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/util/importlib.py", line 88, in import_file_as_module raise FileNotFoundError FileNotFoundError
$ detect-secrets-hook --plugin ./app/detect-secrets/plugins.py --baseline .secrets.baseline ... detect-secrets-hook: error: argument -p/--plugin: ./app/detect-secrets/plugins.py is not a valid file.
$ detect-secrets-hook --baseline .secrets.baseline setup.py detect-secrets-hook: error: plugin referenced in .secrets.baseline: ./path/to/plugin/that/does/not/exist/plugin.py is not a valid file.
$ detect-secrets-hook --baseline .secrets.baseline setup.py Traceback (most recent call last): File "/Users/abramowi/Code/OpenSource/detect-secrets/.venv/bin/detect-secrets-hook", line 8, in
sys.exit(main())
^^^^^^
File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/pre_commit_hook.py", line 30, in main
secrets.scan_file(filename)
File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/core/secrets_collection.py", line 75, in scan_file
for secret in scan.scan_file(os.path.join(self.root, filename)):
File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/core/scan.py", line 141, in scan_file
if not get_plugins(): # pragma: no cover
^^^^^^^^^^^^^
File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/settings.py", line 266, in get_plugins
return [
^
File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/settings.py", line 267, in
plugins.initialize.from_plugin_classname(classname)
File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/core/plugins/initialize.py", line 34, in from_plugin_classname
for plugin_type in get_mapping_from_secret_type_to_class().values():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/core/plugins/util.py", line 43, in get_mapping_from_secret_type_to_class
for plugin_class in get_plugins_from_file(filename):
File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/core/plugins/util.py", line 51, in get_plugins_from_file
for plugin_class in get_plugins_from_module(import_file_as_module(filename)):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/abramowi/Code/OpenSource/detect-secrets/detect_secrets/util/importlib.py", line 88, in import_file_as_module
raise FileNotFoundError
FileNotFoundError