Bug 2192914 - python-oauthlib fails to build with Python 3.12: ValueError: bad query field: ''
Summary: python-oauthlib fails to build with Python 3.12: ValueError: bad query field: ''
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-oauthlib
Version: 39
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michel Lind
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.12
TreeView+ depends on / blocked
 
Reported: 2023-05-03 13:50 UTC by Tomáš Hrnčiar
Modified: 2023-09-28 01:35 UTC (History)
8 users (show)

Fixed In Version: python-oauthlib-3.2.2-1.fc40 python-oauthlib-3.2.2-1.fc39 python-oauthlib-3.2.2-1.fc37 python-oauthlib-3.2.2-1.fc38
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-19 18:35:08 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2023-05-03 13:50:15 UTC
python-oauthlib fails to build with Python 3.12.0a7.

=================================== FAILURES ===================================
____________________ ErrorResponseTest.test_empty_parameter ____________________

self = <oauthlib.Request url="https://example.com/authorize?client_id=foo&redirect_uri=https%3A%2F%2Fi.b%2Fback&response_type=code&", http_method="GET", headers="{}", body="None">

    @property
    def uri_query_params(self):
        if not self.uri_query:
            return []
>       return urlparse.parse_qsl(self.uri_query, keep_blank_values=True,
                                  strict_parsing=True)

oauthlib/common.py:422: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

qs = 'client_id=foo&redirect_uri=https%3A%2F%2Fi.b%2Fback&response_type=code&'
keep_blank_values = True, strict_parsing = True, encoding = 'utf-8'
errors = 'replace', max_num_fields = None, separator = '&'

    def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
                  encoding='utf-8', errors='replace', max_num_fields=None, separator='&'):
        """Parse a query given as a string argument.
    
            Arguments:
    
            qs: percent-encoded query string to be parsed
    
            keep_blank_values: flag indicating whether blank values in
                percent-encoded queries should be treated as blank strings.
                A true value indicates that blanks should be retained as blank
                strings.  The default false value indicates that blank values
                are to be ignored and treated as if they were  not included.
    
            strict_parsing: flag indicating what to do with parsing errors. If
                false (the default), errors are silently ignored. If true,
                errors raise a ValueError exception.
    
            encoding and errors: specify how to decode percent-encoded sequences
                into Unicode characters, as accepted by the bytes.decode() method.
    
            max_num_fields: int. If set, then throws a ValueError
                if there are more than n fields read by parse_qsl().
    
            separator: str. The symbol to use for separating the query arguments.
                Defaults to &.
    
            Returns a list, as G-d intended.
        """
        qs, _coerce_result = _coerce_args(qs)
        separator, _ = _coerce_args(separator)
    
        if not separator or (not isinstance(separator, (str, bytes))):
            raise ValueError("Separator must be of type string or bytes.")
    
        # If max_num_fields is defined then check that the number of fields
        # is less than max_num_fields. This prevents a memory exhaustion DOS
        # attack via post bodies with many fields.
        if max_num_fields is not None:
            num_fields = 1 + qs.count(separator) if qs else 0
            if max_num_fields < num_fields:
                raise ValueError('Max number of fields exceeded')
    
        r = []
        query_args = qs.split(separator) if qs else []
        for name_value in query_args:
            if not name_value and not strict_parsing:
                continue
            nv = name_value.split('=', 1)
            if len(nv) != 2:
                if strict_parsing:
>                   raise ValueError("bad query field: %r" % (name_value,))
E                   ValueError: bad query field: ''

/usr/lib64/python3.12/urllib/parse.py:762: ValueError

The above exception was the direct cause of the following exception:

self = <oauthlib.Request url="https://example.com/authorize?client_id=foo&redirect_uri=https%3A%2F%2Fi.b%2Fback&response_type=code&", http_method="GET", headers="{}", body="None">

    @property
    def duplicate_params(self):
        seen_keys = collections.defaultdict(int)
        all_keys = (p[0]
>                   for p in (self.decoded_body or []) + self.uri_query_params)

oauthlib/common.py:429: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <oauthlib.Request url="https://example.com/authorize?client_id=foo&redirect_uri=https%3A%2F%2Fi.b%2Fback&response_type=code&", http_method="GET", headers="{}", body="None">
name = 'uri_query_params'

    def __getattr__(self, name):
        if name in self._params:
            return self._params[name]
        else:
>           raise AttributeError(name)
E           SystemError: <class 'AttributeError'> returned a result with an exception set

oauthlib/common.py:400: SystemError

The above exception was the direct cause of the following exception:

self = <tests.oauth2.rfc6749.endpoints.test_error_responses.ErrorResponseTest testMethod=test_empty_parameter>

    def test_empty_parameter(self):
        uri = 'https://example.com/authorize?client_id=foo&redirect_uri=https%3A%2F%2Fi.b%2Fback&response_type=code&'
    
        # Authorization code grant
>       self.assertRaises(errors.InvalidRequestFatalError,
                self.web.validate_authorization_request, uri)

tests/oauth2/rfc6749/endpoints/test_error_responses.py:130: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
oauthlib/oauth2/rfc6749/endpoints/base.py:112: in wrapper
    return f(endpoint, uri, *args, **kwargs)
oauthlib/oauth2/rfc6749/endpoints/authorization.py:114: in validate_authorization_request
    return response_type_handler.validate_authorization_request(request)
oauthlib/oauth2/rfc6749/grant_types/authorization_code.py:346: in validate_authorization_request
    duplicate_params = request.duplicate_params
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def __getattr__(self, name):
        if name in self._params:
            return self._params[name]
        else:
>           raise AttributeError(name)
E           SystemError: <class 'AttributeError'> returned a result with an exception set

oauthlib/common.py:400: SystemError
=============================== warnings summary ===============================
tests/oauth2/rfc6749/clients/test_web_application.py::WebApplicationClientTest::test_prepare_request_body
  /builddir/build/BUILD/oauthlib-3.2.1/oauthlib/oauth2/rfc6749/clients/web_application.py:163: DeprecationWarning: `client_id` has been deprecated in favor of `include_client_id`, a boolean value which will include the already configured `self.client_id`.
    warnings.warn("`client_id` has been deprecated in favor of "

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/oauth2/rfc6749/endpoints/test_error_responses.py::ErrorResponseTest::test_empty_parameter
=================== 1 failed, 643 passed, 1 warning in 2.62s ===================


https://docs.python.org/3.12/whatsnew/3.12.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.12/fedora-rawhide-x86_64/05840159-python-oauthlib/

For all our attempts to build python-oauthlib with Python 3.12, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/package/python-oauthlib/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.12:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/

Let us know here if you have any questions.

Python 3.12 is planned to be included in Fedora 39. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.12.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Fedora Release Engineering 2023-08-16 07:13:52 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.

Comment 2 Fedora Update System 2023-09-19 18:33:37 UTC
FEDORA-2023-fab759f7dc has been submitted as an update to Fedora 40. https://bodhi.fedoraproject.org/updates/FEDORA-2023-fab759f7dc

Comment 3 Fedora Update System 2023-09-19 18:35:08 UTC
FEDORA-2023-fab759f7dc has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 4 Fedora Update System 2023-09-19 18:59:19 UTC
FEDORA-2023-da094276a2 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-da094276a2

Comment 5 Fedora Update System 2023-09-19 18:59:20 UTC
FEDORA-2023-49ded4c9a5 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-49ded4c9a5

Comment 6 Fedora Update System 2023-09-19 18:59:20 UTC
FEDORA-2023-5ab7049a59 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-5ab7049a59

Comment 7 Fedora Update System 2023-09-20 01:15:27 UTC
FEDORA-2023-5ab7049a59 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-5ab7049a59`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-5ab7049a59

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Fedora Update System 2023-09-20 02:07:46 UTC
FEDORA-2023-da094276a2 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-da094276a2`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-da094276a2

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 9 Fedora Update System 2023-09-20 02:15:20 UTC
FEDORA-2023-49ded4c9a5 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-49ded4c9a5`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-49ded4c9a5

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2023-09-28 00:19:49 UTC
FEDORA-2023-da094276a2 has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 11 Fedora Update System 2023-09-28 00:48:35 UTC
FEDORA-2023-49ded4c9a5 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 12 Fedora Update System 2023-09-28 01:35:13 UTC
FEDORA-2023-5ab7049a59 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.