From fb9e6371eca303020734e7b672484dcb0e6ff3ed Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 27 Sep 2024 16:30:55 -0400 Subject: [PATCH] Validate `name` in `llama stack build` (#128) The first time I ran `llama stack build`, I quickly hit enter at the first prompt asking for a name, assuming it would use the default given in the help text. This caused a failure later on that wasn't very obvious. I was using the `docker` format and a blank name caused an invalid tag format that failed the image build. This change adds validation for the `name` parameter to ensure it's not empty before proceeding. Signed-off-by: Russell Bryant --- llama_stack/cli/stack/build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/llama_stack/cli/stack/build.py b/llama_stack/cli/stack/build.py index 132aef7e5..2b5b432c8 100644 --- a/llama_stack/cli/stack/build.py +++ b/llama_stack/cli/stack/build.py @@ -199,7 +199,11 @@ class StackBuild(Subcommand): if not args.config and not args.template: if not args.name: name = prompt( - "> Enter a name for your Llama Stack (e.g. my-local-stack): " + "> Enter a name for your Llama Stack (e.g. my-local-stack): ", + validator=Validator.from_callable( + lambda x: len(x) > 0, + error_message="Name cannot be empty, please enter a name", + ), ) else: name = args.name