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

UUID is not JSON serializable when running in taxii2 mode #243

Open
zentavr opened this issue Oct 7, 2022 · 1 comment
Open

UUID is not JSON serializable when running in taxii2 mode #243

zentavr opened this issue Oct 7, 2022 · 1 comment

Comments

@zentavr
Copy link
Contributor

zentavr commented Oct 7, 2022

Hi,

When doing the request like this:

curl --user "rst:pS4vH" https://stix2.***.com/taxii2/d593ad8f-15b9-450e-bc9a-10317165b6c8/collections/

I have an error like this:

[2022-10-07 02:34:37 +0200] [153840] [ERROR] Error handling request /taxii2/d593ad8f-15b9-450e-bc9a-10317165b6c8/collections/
Traceback (most recent call last):
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/server.py", line 909, in handle_request
    return endpoint()
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/server.py", line 475, in handle_request
    return endpoint()
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/utils.py", line 343, in inner
    return method(*args, **kwargs)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/server.py", line 552, in collections_handler
    return make_taxii2_response(response)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/taxii2/http.py", line 11, in make_taxii2_response
    data = json.dumps(data)
  File "/usr/lib/python3.10/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type UUID is not JSON serializable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/gunicorn/workers/sync.py", line 136, in handle
    self.handle_request(listener, req, client, addr)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/gunicorn/workers/sync.py", line 179, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 2548, in __call__
    return self.wsgi_app(environ, start_response)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.handle_exception(e)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1726, in handle_exception
    return self.finalize_request(server_error, from_error_handler=True)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1842, in finalize_request
    response = self.make_response(rv)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 2134, in make_response
    raise TypeError(
TypeError: The view function for 'opentaxii_services_view' did not return a valid response. The function either returned None or ended without a return statement.
[2022-10-07 02:34:44 +0200] [153865] [ERROR] Error handling request /taxii2/d593ad8f-15b9-450e-bc9a-10317165b6c8/collections/
Traceback (most recent call last):
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/server.py", line 909, in handle_request
    return endpoint()
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/server.py", line 475, in handle_request
    return endpoint()
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/utils.py", line 343, in inner
    return method(*args, **kwargs)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/server.py", line 552, in collections_handler
    return make_taxii2_response(response)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/opentaxii/taxii2/http.py", line 11, in make_taxii2_response
    data = json.dumps(data)
  File "/usr/lib/python3.10/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type UUID is not JSON serializable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/gunicorn/workers/sync.py", line 136, in handle
    self.handle_request(listener, req, client, addr)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/gunicorn/workers/sync.py", line 179, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 2548, in __call__
    return self.wsgi_app(environ, start_response)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.handle_exception(e)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1726, in handle_exception
    return self.finalize_request(server_error, from_error_handler=True)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 1842, in finalize_request
    response = self.make_response(rv)
  File "/opt/.otvenv-taxii2/lib/python3.10/site-packages/flask/app.py", line 2134, in make_response
    raise TypeError(
TypeError: The view function for 'opentaxii_services_view' did not return a valid response. The function either returned None or ended without a return statement.

What might be the issue?
Running 0.9.2 from pip.

@andrewbeard
Copy link

This issue blocks a good portion of the TAXII2 functionality. I put a PR in for the same thing before realizing there was an existing issue (and PR). Can someone please take a look at one of the PRs as this is a showstopper for pretty much any TAXII2 user.

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

2 participants