Description of the issue
Backup failed due to duplication of port
Context information (for bug reports)
Just download and install app from github
Output of bench version
erpnext 13.0.0-beta.14
frappe 13.0.0-beta.12
nextcloud_integration 0.0.1
Steps to reproduce the issue
- Configure nextcloud url with a port. Let say https://nextcloud.abc.com:8443. Dav path like /remote.php/dav/files/username
- Provide proper username and password , choose backup frequency and notification email address
- Press Backup Now
Observed result
Backup failed with duplicated port number in the url, says: https://nextcloud.abc.com:8443:8443/.....
Expected result
https://nextcloud.abc.com:8443
Stacktrace / full error message
Error message: Traceback (most recent call last): File "/home/erp/myfrappe/env/lib/python3.8/site-packages/requests/models.py", line 380, in prepare_url scheme, auth, host, port, path, query, fragment = parse_url(url) File "/home/erp/myfrappe/env/lib/python3.8/site-packages/urllib3/util/url.py", line 392, in parse_url return six.raise_from(LocationParseError(source_url), None) File "", line 3, in raise_from urllib3.exceptions.LocationParseError: Failed to parse: https://nextcloud.abc.com:8443:8443/remote.php/dav/files/tuanha/Frappe Backups During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/erp/myfrappe/apps/nextcloud_integration/nextcloud_integration/nextcloud_integration/doctype/nextcloud_setting/nextcloud_setting.py", line 26, in start_taking_backup self.backup_to_nextcloud(upload_db_backup) File "/home/erp/myfrappe/apps/nextcloud_integration/nextcloud_integration/nextcloud_integration/doctype/nextcloud_setting/nextcloud_setting.py", line 58, in backup_to_nextcloud self.check_for_upload_folder() File "/home/erp/myfrappe/apps/nextcloud_integration/nextcloud_integration/nextcloud_integration/doctype/nextcloud_setting/nextcloud_setting.py", line 135, in check_for_upload_folder response = self.session.request("PROPFIND", self.upload_path, headers={"Depth": "0"}, allow_redirects=False) File "/home/erp/myfrappe/env/lib/python3.8/site-packages/requests/sessions.py", line 516, in request prep = self.prepare_request(req) File "/home/erp/myfrappe/env/lib/python3.8/site-packages/requests/sessions.py", line 449, in prepare_request p.prepare( File "/home/erp/myfrappe/env/lib/python3.8/site-packages/requests/models.py", line 314, in prepare self.prepare_url(url, params) File "/home/erp/myfrappe/env/lib/python3.8/site-packages/requests/models.py", line 382, in prepare_url raise InvalidURL(*e.args) requests.exceptions.InvalidURL: Failed to parse: https://nextcloud.abc.com:8443:8443/remote.php/dav/files/tuanha/Frappe Backups
Additional information
Found a bug in the code:
# if not vurl.port:
# port = 443 if vurl.scheme == 'https' else 80
#base_url = '{0}://{1}:{2}'.format(vurl.scheme, vurl.netloc, vurl.port if vurl.port else port)
Should be:
base_url = '{0}://{1}'.format(vurl.scheme, vurl.netloc)
As vurl.netloc already include the port number in Python3, as stated in urllib.parse.urlparse documentation:
https://docs.python.org/3/library/urllib.parse.html
Description of the issue
Backup failed due to duplication of port
Context information (for bug reports)
Just download and install app from github
Output of
bench versionSteps to reproduce the issue
Observed result
Backup failed with duplicated port number in the url, says: https://nextcloud.abc.com:8443:8443/.....
Expected result
https://nextcloud.abc.com:8443
Stacktrace / full error message
Additional information
Found a bug in the code:
# if not vurl.port:
# port = 443 if vurl.scheme == 'https' else 80
Should be:
base_url = '{0}://{1}'.format(vurl.scheme, vurl.netloc)
As vurl.netloc already include the port number in Python3, as stated in urllib.parse.urlparse documentation:
https://docs.python.org/3/library/urllib.parse.html