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

Import Scan fails without 'file' parameter since version 2.41.0 #11560

Open
thedoom13 opened this issue Jan 14, 2025 · 0 comments
Open

Import Scan fails without 'file' parameter since version 2.41.0 #11560

thedoom13 opened this issue Jan 14, 2025 · 0 comments

Comments

@thedoom13
Copy link

thedoom13 commented Jan 14, 2025

This PR has removed the default value of the file parameter.
So when importing a scan without providing file parameter (using the api_scan_configuration), the process fails with
the following error:

ERROR [dojo.api_v2.exception_handler:48] 'file'
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/rest_framework/mixins.py", line 19, in create
self.perform_create(serializer)
File "/app/dojo/api_v2/views.py", line 2517, in perform_create
serializer.save(push_to_jira=push_to_jira)
File "/app/dojo/api_v2/serializers.py", line 2406, in save
context = self.set_context(data)
^^^^^^^^^^^^^^^^^^^^^^
File "/app/dojo/api_v2/serializers.py", line 2375, in set_context
context = self.setup_common_context(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/dojo/api_v2/serializers.py", line 2289, in setup_common_context
context["scan"] = data.pop("file")
^^^^^^^^^^^^^^^^
KeyError: 'file'

Steps to Reproduce:

  • Call the API /api/v2/import-scan to import a scan without including file parameter.
  • The API returns with status 500.

Expected Behavior:

The file parameter is optional, so the API should handle cases where it is not provided gracefully.

Actual Behavior:

The API throws a KeyError when the file parameter is missing.

Additional Context:

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

No branches or pull requests

1 participant