osc-cli
osc-cli copied to clipboard
urllib.parse.urlparse change of behavior using url with port in python3.9
Test without venv in centos7 and in docker python3.9.3 also. Version: v1.7.1 Python3: 3.9.3 Config:
{"default":
{"access_key": "ak",
"secret_key": "sk",
"host": "outscale.com:443",
"https": true,
"method": "POST",
"region_name": "eu-west-2"
}
}
Command launch:
osc-cli api ReadLoadBalancers
You have now :
requests.exceptions.InvalidSchema: No connection adapters were found for 'api.eu-west-2.outscale.com:443//api/latest/ReadLoadBalancers'
Instead of with version python3.7 or python3.6:
osc_sdk.sdk.OscApiException: Error --> status = 401, code = 1, Reason = AccessDenied, request_id = 93acf326-9269-4abb-98b0-c5257c417270
With more investigation the issue is linked with the behavior of urllib.parse.urlparse (the same version in python3.7 and python 3.9 (urllib3==1.24.3)) https://github.com/outscale/osc-cli/blob/master/osc_sdk/sdk.py#L194
In python3.7:
ParseResult(scheme='', netloc='', path='api.eu-west-2.outscale.com:443', params='', query='', fragment='')
In python3.9:
ParseResult(scheme='api.eu-west-2.outscale.com', netloc='', path='443', params='', query='', fragment='')
https://docs.python.org/3/library/urllib.parse.html (Following the syntax specifications in RFC 1808, urlparse recognizes a netloc only if it is properly introduced by ‘//’)
If you have add '//' in endpoint to respect RFC 1808, urllib.parse.urlparse parse correctly:
ParseResult(scheme='', netloc='', path='api.eu-west-2.outscale.com:443', params='', query='', fragment='')