Skip to content

Commit 7a5822e

Browse files
authored
fix(epp): use real flag names in config-file/config-text error (llm-d#1942)
* fix(epp): use real flag names in config-file/config-text error The Validate() error for setting --config-file and --config-text together named the flags "configText" and "configFile", but they are registered as "config-file" and "config-text". Users could not map the message back to a flag. Use the registered kebab-case names, matching every other error in Validate(), and add a regression test asserting both names appear. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com> * fix(epp): use cannot in config flag error Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com> --------- Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
1 parent 19be01c commit 7a5822e

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

pkg/epp/server/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (opts *Options) Validate() error {
299299
}
300300

301301
if opts.ConfigText != "" && opts.ConfigFile != "" {
302-
return fmt.Errorf("both the %q and %q flags can not be set at the same time", "configText", "configFile")
302+
return fmt.Errorf("both the %q and %q flags cannot be set at the same time", "config-file", "config-text")
303303
}
304304
if opts.ModelServerMetricsScheme != "http" && opts.ModelServerMetricsScheme != "https" {
305305
return fmt.Errorf("unexpected %q value for %q flag, it can only be set to 'http' or 'https'",

pkg/epp/server/options_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package server
1818

1919
import (
20+
"strings"
2021
"testing"
2122
"time"
2223

@@ -267,3 +268,20 @@ func TestDrainTimeoutFlag(t *testing.T) {
267268
t.Errorf("DrainTimeout = %v, want 30s", opts.DrainTimeout)
268269
}
269270
}
271+
272+
func TestValidateConfigFlagsMutuallyExclusive(t *testing.T) {
273+
opts := NewOptions()
274+
opts.PoolName = "config-flags-pool" // bypass the pool/selector validation
275+
opts.ConfigFile = "fake-config.yaml"
276+
opts.ConfigText = "fake: config"
277+
278+
err := opts.Validate()
279+
if err == nil {
280+
t.Fatalf("Expected Validate() to fail when both config flags are set, but it succeeded")
281+
}
282+
for _, want := range []string{"config-file", "config-text"} {
283+
if !strings.Contains(err.Error(), want) {
284+
t.Errorf("Validate() error must reference the %q flag, got: %v", want, err)
285+
}
286+
}
287+
}

0 commit comments

Comments
 (0)