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

3.0.1 - JiraCookieAuth - TypeError: session() takes 1 positional argument but 2 were given when creating a JIRA instance with auth=(username,password) #1035

Closed
tevert opened this issue May 12, 2021 · 11 comments · Fixed by #1038 or #1201

Comments

@tevert
Copy link

tevert commented May 12, 2021

Before raising any bug be sure that you used the latest release and that it still reproduces with the latest master. No other version is supported.

Describe the bug
Using the new package published an hour ago, I get a runtime arg error when opening a connection.

To Reproduce

$ python3                                                                                              
Python 3.8.5 (default, Jan 27 2021, 15:41:15)                                                          
[GCC 9.3.0] on linux                                                                                   
Type "help", "copyright", "credits" or "license" for more information.                                 
>>> from jira import JIRA                                                                              
>>> username = 'tevert@motus.com'                                                                      
>>> password = '<REDACTED>'                                                                           
>>> conn = JIRA('https://jira.motus.com', auth = (username, password))                                 
Traceback (most recent call last):                                                                     
  File "<stdin>", line 1, in <module>                                                                  
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 496, in __init__         
    user = self.session()                                                                              
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 2980, in session         
    r = self._session.get(url)                                                                         
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/resilientsession.py", line 172, in get    
    return self.__verb("GET", url, **kwargs)                                                           
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/resilientsession.py", line 143, in __verb 
    response = method(url, timeout=self.timeout, **kwargs)                                             
  File "/home/tevert/.local/lib/python3.8/site-packages/requests/sessions.py", line 543, in get        
    return self.request('GET', url, **kwargs)                                                          
  File "/home/tevert/.local/lib/python3.8/site-packages/requests/sessions.py", line 530, in request    
    resp = self.send(prep, **send_kwargs)                                                              
  File "/home/tevert/.local/lib/python3.8/site-packages/requests/sessions.py", line 650, in send       
    r = dispatch_hook('response', hooks, r, **kwargs)                                                  
  File "/home/tevert/.local/lib/python3.8/site-packages/requests/hooks.py", line 31, in dispatch_hook  
    _hook_data = hook(hook_data, **kwargs)                                                             
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 199, in handle_401       
    self.init_session()                                                                                
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 215, in init_session     
    self.start_session()                                                                               
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 229, in start_session    
    self._get_session(self.__auth)                                                                     
TypeError: session() takes 1 positional argument but 2 were given                                      
>>>                                                                                                    
  1. Any additional steps or considerations that happen before or after.

Expected behavior
I get a connection

Stack Trace

A code block with the any trace messages.

Version Information
Type of Jira instance:

  • [ ] Jira Cloud (Hosted by Atlassian)
  • [ X ] Jira Server or Data Center (Self-hosted)
    Python Interpreter: 3.8
    jira-python: 3..0.1
    OS: WSL Ubuntu
    IPython (Optional):
    Other Dependencies:

Additional context
Add any other context about the problem here.

@tevert
Copy link
Author

tevert commented May 12, 2021

To clarify, this exact code was working fine this morning with version 2.0.0

@studioj
Copy link
Collaborator

studioj commented May 13, 2021

Thx for your issue. I'll help investigate this afternoon.
It's maybe related to the auth changes in jira cloud which we try to support.
@tevert
Do you know which version of jira server you're running?

@studioj
Copy link
Collaborator

studioj commented May 13, 2021

I can repro on jira v8.5.4 => that's a start

@studioj
Copy link
Collaborator

studioj commented May 13, 2021

i think the "auth" parameter was "potentially" misused in prev versions or worked by accident. I don't know the exact history of those parameters.
maybe @ssbarnea could enlighten us (maybe related to commit a4e6b1b )

could you try

conn = JIRA('https://jira.motus.com', basic_auth=(username, password))  

that seems to work for me

if this is the case we might need to add something in the readme to warn people about the changes in v3.0.0

I was going to point you to the documentation here https://jira.readthedocs.io/en/master/api.html#jira.JIRA but i see the documentation for auth is not properly generated. => PR #1038 will fix that

following example in the documentation shows though the usecase you're pointing to
https://jira.readthedocs.io/en/latest/examples.html#cookie-based-authentication
which would suggest that it should work.

I'll start a branch which at least adds a failing test for this

@studioj studioj changed the title Runtime error opening connection with newly published version 3.0.1 - TypeError: session() takes 1 positional argument but 2 were given when creating a JIRA instance with auth=(username,password) May 13, 2021
@studioj
Copy link
Collaborator

studioj commented May 13, 2021

@tevert
Copy link
Author

tevert commented May 13, 2021

basic_auth works fine, thanks for the quick update!

@studioj studioj added bug Needs: Research Needs root cause investigation. labels May 13, 2021
@studioj
Copy link
Collaborator

studioj commented May 13, 2021

@ssbarnea maybe we should also raise a deprecation warning here when people are using Jira Cloud?

its not yet deprecated for jira server so it should work here

https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/

k3muri84 added a commit to k3muri84/generate-changelog that referenced this issue May 14, 2021
with new jira 3.0.1 auth stopped working and has issues with to many params underneath. Using `basic_auth` seem to be more stable approach. See also pycontribs/jira#1035
@dogasantos
Copy link

+1 on cookie based auth.
I have an instance with generic basic_auth in front of Jira for additional security layer.
ty

ssbarnea pushed a commit that referenced this issue May 15, 2021
…1038)

* some part of the documentation wasn't properly generated.
see #1035

* adding warnings about deprecated auth mechanism for jira cloud in examples

* this should fix the mismatch between the white background and the line length of the docs

Co-authored-by: Neefs, Jef <jef.neefs@barco.com>
@studioj
Copy link
Collaborator

studioj commented May 15, 2021

@ssbarnea cookie based login is still broken for jira server...
Was this automatically closed?

@ssbarnea
Copy link
Member

ssbarnea commented May 15, 2021

Based on what I see on screen it seems that that merge did close this ticket even if it did not had a "fixes: #num" block on it. A glitch in the github matrix? Next time just reopen if you think appropiate.

@ssbarnea ssbarnea reopened this May 15, 2021
@Jc-L
Copy link

Jc-L commented Aug 26, 2021

Is there a workaround for this (other than downgrading to 2.0.0) ? It is still failing in the last version

JIRA('https://jira.mydomain.com', auth = (username, password))
[...]
TypeError: session() takes 1 positional argument but 2 were given

@ssbarnea ssbarnea added help wanted and removed Needs: Research Needs root cause investigation. labels Oct 4, 2021
@adehad adehad changed the title 3.0.1 - TypeError: session() takes 1 positional argument but 2 were given when creating a JIRA instance with auth=(username,password) 3.0.1 - JiraCookieAuth - TypeError: session() takes 1 positional argument but 2 were given when creating a JIRA instance with auth=(username,password) Oct 29, 2021
svermeulen pushed a commit to svermeulen/jira that referenced this issue Oct 31, 2021
…ycontribs#1038)

* some part of the documentation wasn't properly generated.
see pycontribs#1035

* adding warnings about deprecated auth mechanism for jira cloud in examples

* this should fix the mismatch between the white background and the line length of the docs

Co-authored-by: Neefs, Jef <jef.neefs@barco.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants