Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Feature/add new activities #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ahouseholder
Copy link

Hi there,

(resubmitting #6 after fixing lint warnings)

I just used the h1 module to retrieve a bunch of reports out of HackerOne. It worked quite well, but I hit into three separate exceptions on different records.

activity-cve-id-added
activity-nobody-assigned-to-bug
duplicate_report_id should be optional
The two activities are present in the data although they are undocumented in the H1 API docs. I also ran across at least one report object that contained an activity-external-user-joined object without the duplicate_report_id attribute, so it seems like marking it as optional is the obvious fix.

…ternalUserJoined now.

Fix for:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/client.py", line 109, in get_resource
    return rsrc_type.get(self, obj_id)
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 171, in get
    return requester.request_object(cls.make_url(obj_id))
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/client.py", line 85, in request_object
    return hydrate_object(data, self)
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 47, in hydrate_object
    return hydrator(requester, obj)
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 162, in __init__
    super(HackerOneResource, self).__init__(requester, raw_data)
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 80, in __init__
    self._handle_data()
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 93, in _handle_data
    self._hydrate()
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 294, in _hydrate
    self._make_relationship("activities", self._hydrate_list_of_objects, [])
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 128, in _make_relationship
    rel_val = hydrator(rel_val["data"])
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 110, in _hydrate_list_of_objects
    return [self._hydrate_object(x) for x in val]
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 110, in <listcomp>
    return [self._hydrate_object(x) for x in val]
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 113, in _hydrate_object
    return hydrate_object(val, self._requester)
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 47, in hydrate_object
    return hydrator(requester, obj)
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 80, in __init__
    self._handle_data()
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 93, in _handle_data
    self._hydrate()
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 411, in _hydrate
    self._activity_hydrate()
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 513, in _activity_hydrate
    self._make_attribute("duplicate_report_id", self._hydrate_verbatim)
  File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 120, in _make_attribute
    attr_val = attrs[attr_name]
KeyError: 'duplicate_report_id'
$ make lint test
flake8 h1 tests
h1/models.py:494:1: E302 expected 2 blank lines, found 1
h1/models.py:495:9: E225 missing whitespace around operator
h1/models.py:497:1: E302 expected 2 blank lines, found 1
h1/models.py:543:1: E302 expected 2 blank lines, found 1
h1/models.py:546:1: E302 expected 2 blank lines, found 1
make: *** [lint] Error 1
@ahouseholder
Copy link
Author

Test data blobs added for the two new activities in commit b2c2dc0

@ahouseholder
Copy link
Author

Finally got it right. :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant