Skip to content

Benevolent validate url#326

Open
iLLiCiTiT wants to merge 7 commits intodevelopfrom
enhancement/benevolent-validate-url
Open

Benevolent validate url#326
iLLiCiTiT wants to merge 7 commits intodevelopfrom
enhancement/benevolent-validate-url

Conversation

@iLLiCiTiT
Copy link
Copy Markdown
Member

@iLLiCiTiT iLLiCiTiT commented Apr 30, 2026

Changelog Description

Validate url function is more benevolent and allows url with path.

Additional review information

Validate url allows to pass in nested url with path e.g. dev.ayon.app/login would be resolved as http://dev.ayon.app. Also fixes issue if localhost url is used without scheme localhost:5000 is resolved as http://localhost:5000, the issue was that localhost was resolved as scheme because of : in the url.

This function is used in ayon launcher for login window.

Testing notes:

  1. Use the function with different options of AYON server url to find out if they are resolved correctly.

This is requirement for ynput/ayon-launcher#208 .

@iLLiCiTiT iLLiCiTiT self-assigned this Apr 30, 2026
@iLLiCiTiT iLLiCiTiT added the type: enhancement New feature or request label Apr 30, 2026
@iLLiCiTiT iLLiCiTiT requested review from BigRoy and kalisp April 30, 2026 12:19
@iLLiCiTiT iLLiCiTiT added the sponsored This is directly sponsored by a client or community member label Apr 30, 2026
Comment thread ayon_api/utils.py Outdated
Comment on lines +803 to +805
if parsed_url.path:
new_path = f"{parsed_url.scheme}{parsed_url.netloc}"
hints.append(f"did you mean \"{new_path}\"?")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this would now also be hinted if you had passed it a completely valid URL but the connection just failed? This may need a check that new_path != url perhaps?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates validate_url to be more tolerant of user-entered AYON server URLs by accepting URLs that include a path (e.g. /login) and by improving handling of inputs like localhost:5000 without an explicit scheme.

Changes:

  • Validate server reachability by requesting the AYON /api/info endpoint.
  • Prepend a default http:// scheme when the input doesn’t specify one.
  • If a path is present, attempt to validate/connect using only the scheme+host portion of the URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ayon_api/utils.py Outdated
"did you mean \"{}\"?".format(parsed_url.scheme + new_path)
)
if parsed_url.path:
new_path = f"{parsed_url.scheme}{parsed_url.netloc}"
Comment thread ayon_api/utils.py
Comment on lines 572 to +578
response = requests.get(
url,
f"{url}/api/info",
timeout=timeout,
verify=verify,
cert=cert,
)
_ = response.json()
Comment thread ayon_api/utils.py Outdated
# Not sure if this is good idea?
modified_url = stripperd_url.rstrip("/")

# Make sure url has http schema
Comment thread ayon_api/utils.py Outdated
Comment on lines +764 to +765
# Make sure url has http schema
if not modified_url.lower().startswith("http"):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sponsored This is directly sponsored by a client or community member type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants