From ad6c83e9235c2c3dbe83e817ebae29ae1f57a532 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 21:55:13 +0000 Subject: [PATCH] Allow --foreground flag with --from-config The --foreground flag is an execution-related flag that controls HOW to run the server (foreground vs detached), not a configuration flag that controls WHAT to run. The runFromConfigFile function already respects this flag, so it should be allowed alongside --from-config. This change modifies the validation logic to use an allowlist of execution-related flags (--foreground, --debug) that can be used with --from-config, while still preventing actual configuration flags from being mixed with --from-config. Fixes #2643 Co-authored-by: Chris Burns --- cmd/thv/app/run.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/thv/app/run.go b/cmd/thv/app/run.go index 4b8325daf..efaefaebe 100644 --- a/cmd/thv/app/run.go +++ b/cmd/thv/app/run.go @@ -485,11 +485,19 @@ func validateRunFlags(cmd *cobra.Command, args []string) error { // Validate --from-config flag usage fromConfigFlag := cmd.Flags().Lookup("from-config") if fromConfigFlag != nil && fromConfigFlag.Value.String() != "" { - // When --from-config is used, no other flags should be changed + // When --from-config is used, only execution-related flags are allowed + // Execution-related flags control HOW to run (foreground vs detached) + // Configuration flags control WHAT to run and should not be mixed with --from-config + allowedFlags := map[string]bool{ + "from-config": true, + "foreground": true, + "debug": true, // Debug is also an execution flag + } + var conflictingFlags []string cmd.Flags().VisitAll(func(flag *pflag.Flag) { - // Skip the from-config flag itself and only check flags that were changed - if flag.Name != "from-config" && flag.Changed { + // Skip allowed flags and only check flags that were changed + if !allowedFlags[flag.Name] && flag.Changed { conflictingFlags = append(conflictingFlags, "--"+flag.Name) } })