Skip to content

Commit f2d45b2

Browse files
committed
fix: validate endpoint url
currently `llama-stack-client configure` allows a user to set up with a valid 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 Signed-off-by: Charlie Doern <cdoern@redhat.com>
1 parent 96749af commit f2d45b2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ tqdm==4.67.1
5454
typing-extensions==4.7.1 ; python_full_version < '3.8'
5555
typing-extensions==4.12.2 ; python_full_version >= '3.8'
5656
tzdata==2025.1 ; python_full_version >= '3.8'
57+
validators==0.34.0
5758
wcwidth==0.2.13
5859
zipp==3.15.0 ; python_full_version < '3.8'

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+
import validators
1314

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

@@ -36,8 +37,8 @@ def configure(endpoint: str | None, api_key: str | None):
3637
final_endpoint = prompt(
3738
"> Enter the endpoint of the Llama Stack distribution server: ",
3839
validator=Validator.from_callable(
39-
lambda x: len(x) > 0,
40-
error_message="Endpoint cannot be empty, please enter a valid endpoint",
40+
lambda x: len(x) > 0 and validators.url(x),
41+
error_message="Endpoint cannot be empty and must be a valid URL, please enter a valid endpoint",
4142
),
4243
)
4344

0 commit comments

Comments
 (0)