Skip to content

Commit 6fa8095

Browse files
authored
fix: validate endpoint url (#196)
# What does this PR do? currently `llama-stack-client configure` allows a user to set up with a invalid URL such as ` ['::', '0.0.0.0']:8321` and then any subsequent command fails due to improperly reading the bad URL from the config.yaml ## Test Plan after: <img width="775" alt="Screenshot 2025-03-12 at 2 03 14 PM" src="https://github.com/user-attachments/assets/746d1e13-b8e7-4ad9-99dd-6e50069c2641" /> Signed-off-by: Charlie Doern <cdoern@redhat.com>
1 parent 6191aa5 commit 6fa8095

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/llama_stack_client/lib/cli/configure.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import yaml
1111
from prompt_toolkit import prompt
1212
from prompt_toolkit.validation import Validator
13+
from urllib.parse import urlparse
1314

1415
from llama_stack_client.lib.cli.constants import LLAMA_STACK_CLIENT_CONFIG_DIR, get_config_file_path
1516

@@ -37,8 +38,8 @@ def configure(endpoint: str | None, api_key: str | None):
3738
final_endpoint = prompt(
3839
"> Enter the endpoint of the Llama Stack distribution server: ",
3940
validator=Validator.from_callable(
40-
lambda x: len(x) > 0,
41-
error_message="Endpoint cannot be empty, please enter a valid endpoint",
41+
lambda x: len(x) > 0 and (parsed := urlparse(x)).scheme and parsed.netloc,
42+
error_message="Endpoint cannot be empty and must be a valid URL, please enter a valid endpoint",
4243
),
4344
)
4445

0 commit comments

Comments
 (0)