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

Importing an entire assessment fails with a 500 error resulting from a validation error #34

Open
binarysamurais opened this issue Dec 9, 2024 · 2 comments

Comments

@binarysamurais
Copy link

Steps to reproduce:

  1. Create an Assessment
  2. Export entire assessment via Export...>Entire Assessment
  3. Save Zip File
  4. Navigate back to Assessments
  5. Click Import Assessment
  6. Locate and select recently exported assessment

Expected result: Assessment imported successfully

Actual result:
500 error on /asssement/import/entire API call
Inner exception on blueprints/asessment_import.py line 137 in importentire at newTestcase.save()
Inner Inner exception raise ValidationError(message, errors=errors) mongoengine.errors.ValidationError: Validation Error (TestCase:None) (Field is required: ['name'])

Initial observations:

It appears that the code is attempting to save the testCase object to mongo at line 137 before some required fields are set this causes a validation error. This appears to be so that we can set testcaseID to the id returned by mongo to be used in the creation of the path for the testcase files. at line 182. Recommendation either set required fields before calling newTestcase.save() at line 137

[2024-12-09 22:01:17 +0000] [17] [ERROR] Error handling request /assessments/assessment/import/entire Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 135, in handle self.handle_request(listener, req, client, addr) File "/usr/local/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 178, in handle_request respiter = self.wsgi(environ, resp.start_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2552, in __call__ return self.wsgi_app(environ, start_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2532, in wsgi_app response = self.handle_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2529, in wsgi_app response = self.full_dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/flask_security/decorators.py", line 394, in decorated_view return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/flask_security/decorators.py", line 513, in decorated_view return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/usr/src/app/blueprints/assessment_import.py", line 137, in importentire newTestcase.save() File "/usr/local/lib/python3.11/site-packages/mongoengine/document.py", line 399, in save self.validate(clean=clean) File "/usr/local/lib/python3.11/site-packages/mongoengine/base/document.py", line 438, in validate raise ValidationError(message, errors=errors) mongoengine.errors.ValidationError: ValidationError (TestCase:None) (Field is required: ['name'])

@binarysamurais
Copy link
Author

Default_ DLP_ControlTest.zip
is an example assessment to import

@binarysamurais
Copy link
Author

Bump

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