Skip to content

User defined proxies not used properly #2398

@JohnnyNr05

Description

@JohnnyNr05

Bug summary

Minimal example

Prerequisites

The user needs to have an environment variable for the http_proxy and https_proxy set.

import os
import jira

# Let's assume that the user has the following env variables set (for whatever reason). 
# For the sake of this minimal example, let's actively set these env variables. 
# Please note that the http:// prefix is missing. 
os.environ['http_proxy'] = 'localhost:3128'
os.environ['https_proxy'] = 'localhost:3128'

# Connection to Jira
access_token = "<ACCESS_TOKEN>"
options = {'server': "SERVER"}
proxies = {'http': 'http://localhost:3128', 'https': 'http://localhost:3128'} # <<< Please not that the user specifies here the actual poxy that should be used! 
jira = JIRA(options=options, token_auth=access_token, proxies=proxies, max_retries=0)

Example is failing with the following error message:
requests.exceptions.InvalidProxyURL: Please check proxy URL. It is malformed and could be missing the host.

Reason:
When constructing the JIRA object, the function server_info() is failing.
Internally, class ResilientSession is not properly passing the self.proxies settings when super().request function is called.

Is there an existing issue for this?

  • I have searched the existing issues

Jira Instance type

Jira Server or Data Center (Self-hosted)

Jira instance version

No response

jira-python version

main

Python Interpreter version

3.12

Which operating systems have you used?

  • Linux
  • macOS
  • Windows

Reproduction steps

import os
import jira

# Let's assume that the user has the following env variables set (for whatever reason). 
# For the sake of this minimal example, let's activity set these env variables. 
# Please note that the http:// prefix is missing. 
os.environ['http_proxy'] = 'localhost:1234'
os.environ['https_proxy'] = 'localhost:1234'

# Connection to Jira
access_token = "<ACCESS_TOKEN>"
options = {'server': "SERVER"}
proxies = {'http': 'http://localhost:1234', 'https': 'http://localhost:1234'} # <<< Please not that the user specifies here the actual poxy that should be used! 
jira = JIRA(options=options, token_auth=access_token, proxies=proxies, max_retries=0)

Stack trace

site-packages/requests/adapters.py", line 456, in get_connection_with_tls_context
    raise InvalidProxyURL(
    ...<2 lines>...
    )
requests.exceptions.InvalidProxyURL: Please check proxy URL. It is malformed and could be missing the host.

Expected behaviour

Jira object should be constructed with proxy settings that user defined as input parameter.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions