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

Resource RequestType is broken in 3.x #1130

Closed
bmathieu33 opened this issue Aug 27, 2021 · 2 comments · Fixed by #1133
Closed

Resource RequestType is broken in 3.x #1130

bmathieu33 opened this issue Aug 27, 2021 · 2 comments · Fixed by #1133
Labels

Comments

@bmathieu33
Copy link
Contributor

bmathieu33 commented Aug 27, 2021

The class cannot be instanciated with raw content, since v3.

The commit b07a074abf6773c has changed RequestType.__init__ method, trying to parse raw content before having called Resource.__init__(). This leads to this kind of traceback, using release 3.0.1:

jira/resources.py", line 1015, in __init__
     self._parse_raw(raw)
jira/resources.py", line 403, in _parse_raw
     dict2resource(raw, self, self._options, self._session)
jira/resources.py", line 199, in __getattr__
     raise AttributeError(
 AttributeError: <class 'jira.resources.RequestType'> object has no attribute '_options' ('RequestType' object is not subscriptable)

Other resource classes have not been changed, so it seems this changed has been introduced by accident.

To reproduce:

from jira.resources import RequestType
RequestType({}, None, {"some_attr": True})

Traceback:

Traceback (most recent call last):
  File "venv/lib/python3.9/site-packages/jira/resources.py", line 183, in __getattr__
    return self[item]
TypeError: 'RequestType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "venv/lib/python3.9/site-packages/jira/resources.py", line 1015, in __init__
    self._parse_raw(raw)
  File "venv/lib/python3.9/site-packages/jira/resources.py", line 403, in _parse_raw
    dict2resource(raw, self, self._options, self._session)
  File "venv/lib/python3.9/site-packages/jira/resources.py", line 199, in __getattr__
    raise AttributeError(
AttributeError: <class 'jira.resources.RequestType'> object has no attribute '_options' ('RequestType' object is not subscriptable)
@studioj studioj added the bug label Aug 28, 2021
@studioj
Copy link
Collaborator

studioj commented Aug 28, 2021

@bmathieu33 Thanks for your report. Could you edit your issue with a simple way to reproduce...

that would be awesome.

Thx for investigating the commits and dont hesitate to create a fork and open a PR to possibly fix this (who knows with a test to validate its fix ;-))

@bmathieu33
Copy link
Contributor Author

@studioj I have added a simple way to reproduce, and a small PR to fix this.

Sorry I cannot take the time investigate more how to add a test. I searched and found no tests case was already set up for this resource (only an empty file).

adehad pushed a commit that referenced this issue Sep 18, 2021
…1133)

* fix TB on RequestType instanciation with raw content (fixes #1130)
svermeulen pushed a commit to svermeulen/jira that referenced this issue Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants