oasis-open / cti-taxii-client

OASIS TC Open Repository: TAXII 2 Client Library Written in Python
https://taxii2client.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
108 stars 52 forks source link

Fix for issue #113, AttributeError: 'dict' object has no attribute 'json' exception #114

Closed andrewbeard closed 1 year ago

andrewbeard commented 1 year ago

Right now _HTTPConnection.get() can return either a dict or a requests.Response depending on what it thinks the calling function wants. This creates some type confusion, and in certain circumstances results in _to_json being called on a dict instead of a Response, causing an exception.

There are a bunch of different ways to work around this, but I took the route of trying to fix the base type conduction problem by wrapping the requests.Response in an object that can satisfy both the callers that want a dict or the headers from requests.Response and making the get behavior consistent. That means the _to_json calls can be removed and the exception never fires.

All unit tests pass, but I haven't been able to sign off on the CLA yet as the link for it no longer appears to function (https://www.oasis-open.org/resources/open-repositories/cla/individual-cla). If someone can point me to one that works I'll get it taken care of.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

andrewbeard commented 1 year ago

Well, that sucks. It looks like the CI tests are all broken.

andrewbeard commented 1 year ago

I've got a new that fixes the workflows up here: https://github.com/oasis-open/cti-taxii-client/pull/116

Once that gets merged in hopefully we can rerun the checks and get this one moving.

codecov-commenter commented 1 year ago

Codecov Report

Merging #114 (31d3c5a) into master (c44ca80) will increase coverage by 0.01%. The diff coverage is 100.00%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
+ Coverage   96.42%   96.44%   +0.01%     
==========================================
  Files           8        8              
  Lines        1988     1999      +11     
==========================================
+ Hits         1917     1928      +11     
  Misses         71       71              
Impacted Files Coverage Δ
taxii2client/common.py 88.96% <100.00%> (+0.84%) :arrow_up:
taxii2client/v20/__init__.py 94.10% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more