Repository: kurtosis-tech/kurtosis
Pull request #412 (2023-03-30 17:39:49)

refactor!: Moved the `sevice_name` argument to the first position in the `exec`, `request`, and `wait` instructions, users will have to adapt these instructions calls if where using positional arguments.
## Description:
Moved the `sevice_name` argument to the first position in the `exec`, `request`, and `wait` instructions

## Is this change user facing?
YES

## References (if applicable):
<!-- Add relevant Github Issues, Discord threads, or other helpful information. -->


cloudflare-pages[bot]: ## Deploying with &nbsp;<a href="https://pages.dev"><img alt="Cloudflare Pages" src="https://user-images.githubusercontent.com/23264/106598434-9e719e00-654f-11eb-9e59-6167043cfa01.png" width="16"></a> &nbsp;Cloudflare Pages

<table><tr><td><strong>Latest commit:</strong> </td><td>
<code>d9dd74a</code>
</td></tr>
<tr><td><strong>Status:</strong></td><td>&nbsp;✅&nbsp; Deploy successful!</td></tr>
<tr><td><strong>Preview URL:</strong></td><td>
<a href='https://01d0def0.kurtosis-docs.pages.dev'>https://01d0def0.kurtosis-docs.pages.dev</a>
</td></tr>
<tr><td><strong>Branch Preview URL:</strong></td><td>
<a href='https://lporoli-move-service-name-ar.kurtosis-docs.pages.dev'>https://lporoli-move-service-name-ar.kurtosis-docs.pages.dev</a>
</td></tr>
</table>

[View logs](https://dash.cloudflare.com/?to=/:account/pages/view/kurtosis-docs/01d0def0-b8f0-4235-bc5e-7566bc907147)


Patch:
diff --git a/cli/cli/command_framework/lowlevel/lowlevel_kurtosis_command.go b/cli/cli/command_framework/lowlevel/lowlevel_kurtosis_command.go
index bfc30a50c..d013b4c9a 100644
--- a/cli/cli/command_framework/lowlevel/lowlevel_kurtosis_command.go
+++ b/cli/cli/command_framework/lowlevel/lowlevel_kurtosis_command.go
@@ -2,11 +2,9 @@ package lowlevel
 
 import (
 	"context"
-	"errors"
 	"fmt"
 	"github.com/kurtosis-tech/kurtosis/cli/cli/command_framework/lowlevel/args"
 	"github.com/kurtosis-tech/kurtosis/cli/cli/command_framework/lowlevel/flags"
-	"github.com/kurtosis-tech/kurtosis/cli/cli/out"
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/sirupsen/logrus"
 	"github.com/spf13/cobra"
@@ -15,8 +13,6 @@ import (
 
 const (
 	shouldLogCompletionDebugMessagesToStderr = true
-	separator                                = "---"
-	removeTrailingSpecialCharacter           = "\n"
 )
 
 // LowlevelKurtosisCommand is the most configurable, lowest-level implementation of the KurtosisCommand interface
@@ -375,36 +371,3 @@ func renderArgUsageStr(arg *args.ArgConfig) string {
 	}
 	return result
 }
-
-//TODO: this is currently not integrated but will do once all the necessary PRs are merged.
-//nolint:all
-func getErrorMessageToBeDisplayedOnCli(err error) error {
-	fileLogger, err := out.GetFileLogger()
-	if err != nil {
-		return stacktrace.Propagate(err, "")
-	}
-	fileLogger.Error(err)
-	// if we are running in the debug mode, just return the error with stack-traces
-	if logrus.GetLevel() == logrus.DebugLevel {
-		return err
-	}
-
-	errorMessage := err.Error()
-	cleanError := removeFilePathFromErrorMessage(errorMessage)
-	return cleanError
-}
-
-// this method removes the file path from the error
-func removeFilePathFromErrorMessage(errorMessage string) error {
-	errorMessageConvertedInList := strings.Split(errorMessage, separator)
-
-	// only the even numbered elements needs to be picked.
-	var cleanErrorList []string
-	for index, line := range errorMessageConvertedInList {
-		if index%2 == 0 {
-			cleanErrorList = append(cleanErrorList, strings.Trim(line, removeTrailingSpecialCharacter))
-		}
-	}
-
-	return errors.New(strings.Join(cleanErrorList, ""))
-}
diff --git a/cli/cli/commands/feedback/feedback.go b/cli/cli/commands/feedback/feedback.go
index a041027ec..a48951e9c 100644
--- a/cli/cli/commands/feedback/feedback.go
+++ b/cli/cli/commands/feedback/feedback.go
@@ -291,7 +291,7 @@ func validateUserMsgArg(_ context.Context, _ *flags.ParsedFlags, args *args.Pars
 	}
 
 	if userMsgArg == "" {
-		return stacktrace.Propagate(err, "Error validating the user message argument, it can be an empty string")
+		return stacktrace.NewError("Error validating the user message argument, it can not be an empty string")
 	}
 	return nil
 }
diff --git a/cli/cli/commands/root.go b/cli/cli/commands/root.go
index 2618f3b9d..3524dc2cd 100644
--- a/cli/cli/commands/root.go
+++ b/cli/cli/commands/root.go
@@ -7,6 +7,7 @@ package commands
 
 import (
 	"encoding/json"
+	"fmt"
 	"github.com/Masterminds/semver/v3"
 	"github.com/kurtosis-tech/kurtosis/cli/cli/command_str_consts"
 	"github.com/kurtosis-tech/kurtosis/cli/cli/commands/analytics"
@@ -37,6 +38,7 @@ import (
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/sirupsen/logrus"
 	"github.com/spf13/cobra"
+	"github.com/spf13/pflag"
 	"io"
 	"io/ioutil"
 	"net/http"
@@ -85,7 +87,10 @@ var RootCmd = &cobra.Command{
 	Short: "A CLI for interacting with the Kurtosis engine",
 	// Cobra will print usage whenever _any_ error occurs, including ones we throw in Kurtosis
 	// This doesn't make sense in 99% of the cases, so just turn them off entirely
-	SilenceUsage:      true,
+	SilenceUsage: true,
+	// Cobra prints the errors itself, however, with this flag disabled it give Kurtosis control
+	// and allows us to post process the error in the main.go file.
+	SilenceErrors:     true,
 	PersistentPreRunE: globalSetup,
 }
 
@@ -127,11 +132,6 @@ func globalSetup(cmd *cobra.Command, args []string) error {
 	if err := setupCLILogs(cmd); err != nil {
 		return stacktrace.Propagate(err, "An error occurred setting up CLI logs")
 	}
-
-	if err := out.SetupFileLogger(); err != nil {
-		return stacktrace.Propagate(err, "An error occurred while setting up the logging to a file.")
-	}
-
 	checkCLIVersion(cmd)
 	//It is necessary to try track this metric on every execution to have at least one successful deliver
 	if err := user_send_metrics_election.SendAnyBackloggedUserMetricsElectionEvent(); err != nil {
@@ -139,9 +139,37 @@ func globalSetup(cmd *cobra.Command, args []string) error {
 		logrus.Debugf("An error occurred tracking user consent to send metrics election\n%v", err)
 	}
 
+	printKurtosisCommandToFile(cmd, args)
 	return nil
 }
 
+func printKurtosisCommandToFile(cmd *cobra.Command, args []string) {
+	// silently fail if there is an error accessing file logger
+	// downside is that we would not be storing the logs in the file, so could lose
+	// stack-traces and users may need to use --debug flag to get the entire stack-trace
+	fileLogger, err := out.GetFileLogger()
+	if err != nil {
+		logrus.Debugf("Error occurred while getting the file logger %+v", err)
+	} else {
+		flagsSetByUsers := getFlagsSetByUsers(cmd.Flags())
+		fileLogger.Infof("===== Executing Command: kurtosis %v %v %v =====",
+			cmd.Name(),
+			strings.Join(flagsSetByUsers, " "),
+			strings.Join(args, " "),
+		)
+	}
+
+}
+
+func getFlagsSetByUsers(flagSet *pflag.FlagSet) []string {
+	var flagsSetByUser []string
+	visitOnlySetFlags := func(flag *pflag.Flag) {
+		flagsSetByUser = append(flagsSetByUser, fmt.Sprintf("--%v", flag.Name), flag.Value.String())
+	}
+	flagSet.Visit(visitOnlySetFlags)
+	return flagsSetByUser
+}
+
 func setupCLILogs(cmd *cobra.Command) error {
 	logLevel, err := logrus.ParseLevel(logLevelStr)
 	if err != nil {
diff --git a/cli/cli/main.go b/cli/cli/main.go
index f6b97dbf9..250a373fe 100644
--- a/cli/cli/main.go
+++ b/cli/cli/main.go
@@ -6,9 +6,12 @@
 package main
 
 import (
+	"errors"
 	"github.com/kurtosis-tech/kurtosis/cli/cli/commands"
+	"github.com/kurtosis-tech/kurtosis/cli/cli/out"
 	"github.com/sirupsen/logrus"
 	"os"
+	"strings"
 )
 
 const (
@@ -17,6 +20,12 @@ const (
 
 	forceColors   = true
 	fullTimestamp = true
+
+	separator                      = "---"
+	removeTrailingSpecialCharacter = "\n"
+	errorNotCreatedFromStacktrace  = 1
+	errorPrefix                    = "Error: "
+	commandNotFound                = "unknown command"
 )
 
 func main() {
@@ -40,8 +49,59 @@ func main() {
 	})
 
 	if err := commands.RootCmd.Execute(); err != nil {
-		// We don't actually need to print the error because Cobra will do it for us
+		maybeCleanedError := getErrorMessageToBeDisplayedOnCli(err)
+		errorMessageFromCli := maybeCleanedError.Error()
+		// cobra uses this method underneath as well to print errors
+		// so just used it directly.
+		commands.RootCmd.PrintErrln(errorPrefix, errorMessageFromCli)
+
+		// if unknown command is entered - display help command
+		if strings.Contains(errorMessageFromCli, commandNotFound) {
+			commands.RootCmd.PrintErrf("Run '%v --help' for usage.\n", commands.RootCmd.CommandPath())
+		}
 		os.Exit(errorExitCode)
 	}
 	os.Exit(successExitCode)
 }
+
+func getErrorMessageToBeDisplayedOnCli(errorWithStacktrace error) error {
+	// if we are running in the debug mode, just return the error with stack-traces back to the client
+	if logrus.GetLevel() == logrus.DebugLevel {
+		return errorWithStacktrace
+	}
+
+	// silently catch the file logger error and print it in the debug mode
+	// users should not worry about this error
+	// downside is that we may lose stack-traces during file logger failures
+	fileLogger, err := out.GetFileLogger()
+	if err != nil {
+		logrus.Warnf("Error occurred while getting the file logger %+v", err)
+	} else {
+		fileLogger.Errorln(errorWithStacktrace.Error())
+	}
+
+	errorMessage := errorWithStacktrace.Error()
+	cleanError := removeFilePathFromErrorMessage(errorMessage)
+	return cleanError
+}
+
+// this method removes the file path from the error
+func removeFilePathFromErrorMessage(errorMessage string) error {
+	errorMessageConvertedInList := strings.Split(errorMessage, separator)
+	// safe to assume that the error was not generated using stacktrace package
+	if len(errorMessageConvertedInList) == errorNotCreatedFromStacktrace {
+		return errors.New(errorMessage)
+	}
+
+	// only the even numbered elements needs to be picked.
+	var cleanErrorList []string
+	for index, line := range errorMessageConvertedInList {
+		if index%2 == 0 {
+			cleanErrorMsgLine := strings.Trim(line, removeTrailingSpecialCharacter)
+			cleanErrorList = append(cleanErrorList, cleanErrorMsgLine)
+		}
+	}
+
+	cleanErrorMessage := strings.Join(cleanErrorList, "")
+	return errors.New(cleanErrorMessage)
+}
diff --git a/cli/cli/out/file_logger.go b/cli/cli/out/file_logger.go
index ee827fa5e..c831dd6b1 100644
--- a/cli/cli/out/file_logger.go
+++ b/cli/cli/out/file_logger.go
@@ -11,23 +11,23 @@ import (
 
 var once sync.Once
 
-// FileLogger this logger will only log to a file
 // TODO: In commands like inspect we use out.PrintOutLn - will need to add this fileLogger
 //  to print commands' output as well.
-var fileLogger = logrus.New()
+// fileLogger this logger will only log to a file
+var fileLogger *logrus.Logger
 var permission = fs.FileMode(0666)
 
-func SetupFileLogger() error {
+func GetFileLogger() (*logrus.Logger, error) {
 	var err error
-	once.Do(func() {
-		err = setupFileLogger()
-	})
-	return err
-}
 
-func GetFileLogger() (*logrus.Logger, error) {
 	if fileLogger == nil {
-		return nil, stacktrace.NewError("File logger is not initialized. This error most likely represents that there is a bug with kurtosis; please use kurtosis feedback to report it.")
+		once.Do(func() {
+			err = setupFileLogger()
+		})
+	}
+
+	if err != nil {
+		return nil, stacktrace.Propagate(err, "Error occurred while getting the file logger")
 	}
 	return fileLogger, nil
 }
@@ -51,12 +51,11 @@ func setupFileLogger() error {
 	}
 
 	// this is the formatter using for fileLogger
-	// TODO: Seeing weird characters in the log file - will look into fixing it in next PR
 	textFormatter := &logrus.TextFormatter{
 		ForceColors:               false,
 		DisableColors:             true,
 		ForceQuote:                false,
-		DisableQuote:              false,
+		DisableQuote:              true,
 		EnvironmentOverrideColors: false,
 		DisableTimestamp:          false,
 		FullTimestamp:             false,
@@ -70,6 +69,7 @@ func setupFileLogger() error {
 		CallerPrettyfier:          nil,
 	}
 
+	fileLogger = logrus.New()
 	fileLogger.SetOutput(logFile)
 	fileLogger.SetLevel(logrus.InfoLevel)
 	fileLogger.SetFormatter(textFormatter)
@@ -80,10 +80,10 @@ func setupFileLogger() error {
 		logrus.DebugLevel,
 		logrus.ErrorLevel,
 	}
+
 	// added logrus hook which automatically make sure that all the logging is being done in the file as well
 	// currently only info, warn, debug and error level logs are added to the file but we can add more later.
 	logsHook := NewHook(logFile, logLevels, textFormatter)
 	logrus.AddHook(&logsHook)
-
 	return nil
 }
diff --git a/cli/cli/out/hook.go b/cli/cli/out/hook.go
index 41bd753af..f79e14593 100644
--- a/cli/cli/out/hook.go
+++ b/cli/cli/out/hook.go
@@ -9,11 +9,6 @@ import (
 
 const logFileName = "kurtosis-cli.log"
 
-// this is needed to silently log fire failures to the cli on --debug level
-// the default logger has the hook attached to it. Using the same logger in the fire method
-// for the hook would result in recursive condition
-var silentFailureLogger = logrus.New()
-
 // Hook is a hook that writes logs of specified LogLevels to specified Writer
 type Hook struct {
 	writer    io.Writer
@@ -29,15 +24,19 @@ func NewHook(writer io.Writer, logLevels []logrus.Level, formatter logrus.Format
 	}
 }
 
+// Fire This hook is called whenever default logrus is to log messages; therefore
+// cannot use it logrus default logger in this method to avoid recursive behaviour
+// therefore using logrus.StandardLogger to log failures with this method onto the
+// terminal only during debug level.
 func (hook *Hook) Fire(entry *logrus.Entry) error {
 	line, err := hook.formatter.Format(entry)
 	if err != nil {
-		silentFailureLogger.Debug(fmt.Sprintf("Error occurred while formatting log message for: %+v", entry))
+		logrus.StandardLogger().Debug(fmt.Sprintf("Error occurred while formatting log message for: %+v", entry))
 		return nil
 	}
 	_, err = hook.writer.Write(line)
 	if err != nil {
-		silentFailureLogger.Debug(fmt.Sprintf("Error occurred writing the log message to the file: %v for: %+v", logFileName, entry))
+		logrus.StandardLogger().Debug(fmt.Sprintf("Error occurred writing the log message to the file: %v for: %+v", logFileName, entry))
 	}
 	return nil
 }
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go
index c02b514c4..980ea6472 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go
@@ -38,12 +38,6 @@ func NewExec(serviceNetwork service_network.ServiceNetwork, runtimeValueStore *r
 		KurtosisBaseBuiltin: &kurtosis_starlark_framework.KurtosisBaseBuiltin{
 			Name: ExecBuiltinName,
 			Arguments: []*builtin_argument.BuiltinArgument{
-				{
-					Name:              RecipeArgName,
-					IsOptional:        false,
-					ZeroValueProvider: builtin_argument.ZeroValueProvider[*recipe.ExecRecipe],
-					Validator:         nil,
-				},
 				{
 					Name:              ServiceNameArgName,
 					IsOptional:        false,
@@ -52,6 +46,12 @@ func NewExec(serviceNetwork service_network.ServiceNetwork, runtimeValueStore *r
 						return builtin_argument.NonEmptyString(value, ServiceNameArgName)
 					},
 				},
+				{
+					Name:              RecipeArgName,
+					IsOptional:        false,
+					ZeroValueProvider: builtin_argument.ZeroValueProvider[*recipe.ExecRecipe],
+					Validator:         nil,
+				},
 				{
 					Name:              AcceptableCodesArgName,
 					IsOptional:        true,
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go
index a965f2af7..a012068b0 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go
@@ -49,12 +49,6 @@ func NewRequest(serviceNetwork service_network.ServiceNetwork, runtimeValueStore
 			Name: RequestBuiltinName,
 
 			Arguments: []*builtin_argument.BuiltinArgument{
-				{
-					Name:              RecipeArgName,
-					IsOptional:        false,
-					ZeroValueProvider: builtin_argument.ZeroValueProvider[*recipe.HttpRequestRecipe],
-					Validator:         nil,
-				},
 				{
 					Name:              ServiceNameArgName,
 					IsOptional:        false,
@@ -63,6 +57,12 @@ func NewRequest(serviceNetwork service_network.ServiceNetwork, runtimeValueStore
 						return builtin_argument.NonEmptyString(value, ServiceNameArgName)
 					},
 				},
+				{
+					Name:              RecipeArgName,
+					IsOptional:        false,
+					ZeroValueProvider: builtin_argument.ZeroValueProvider[*recipe.HttpRequestRecipe],
+					Validator:         nil,
+				},
 				{
 					Name:              AcceptableCodesArgName,
 					IsOptional:        true,
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go
index 008898b48..ae53add45 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go
@@ -40,6 +40,14 @@ func NewWait(serviceNetwork service_network.ServiceNetwork, runtimeValueStore *r
 			Name: WaitBuiltinName,
 
 			Arguments: []*builtin_argument.BuiltinArgument{
+				{
+					Name:              ServiceNameArgName,
+					IsOptional:        false,
+					ZeroValueProvider: builtin_argument.ZeroValueProvider[starlark.String],
+					Validator: func(value starlark.Value) *startosis_errors.InterpretationError {
+						return builtin_argument.NonEmptyString(value, ServiceNameArgName)
+					},
+				},
 				{
 					Name:              RecipeArgName,
 					IsOptional:        false,
@@ -76,14 +84,6 @@ func NewWait(serviceNetwork service_network.ServiceNetwork, runtimeValueStore *r
 					ZeroValueProvider: builtin_argument.ZeroValueProvider[starlark.String],
 					Validator:         nil,
 				},
-				{
-					Name:              ServiceNameArgName,
-					IsOptional:        false,
-					ZeroValueProvider: builtin_argument.ZeroValueProvider[starlark.String],
-					Validator: func(value starlark.Value) *startosis_errors.InterpretationError {
-						return builtin_argument.NonEmptyString(value, ServiceNameArgName)
-					},
-				},
 			},
 		},
 
diff --git a/docs/docs/reference/starlark-instructions.md b/docs/docs/reference/starlark-instructions.md
index 328984da0..c34cd0d70 100644
--- a/docs/docs/reference/starlark-instructions.md
+++ b/docs/docs/reference/starlark-instructions.md
@@ -185,6 +185,11 @@ exec_recipe = ExecRecipe(
 )
 
 result = plan.exec(
+    # A Service name designating a service that already exists inside the enclave
+    # If it does not, a validation error will be thrown
+    # MANDATORY
+    service_name = "my-service",
+    
     # The recipe that will determine the exec to be performed.
     # Valid values are of the following types: (ExecRecipe)
     # MANDATORY
@@ -198,11 +203,6 @@ result = plan.exec(
     # You can chain this call with assert to check codes after request is done.
     # OPTIONAL (Defaults to False)
     skip_code_check = False,
-
-    # A Service name designating a service that already exists inside the enclave
-    # If it does not, a validation error will be thrown
-    # MANDATORY
-    service_name = "my-service",
 )
 
 plan.print(result["output"])
@@ -337,6 +337,11 @@ To make a GET or POST request, simply set the `recipe` field to use the specifie
 
 ```python
 http_response = plan.request(
+    # A service name designating a service that already exists inside the enclave
+    # If it does not, a validation error will be thrown
+    # MANDATORY
+    service_name = "my_service",
+    
     # The recipe that will determine the request to be performed.
     # Valid values are of the following types: (GetHttpRequestRecipe, PostHttpRequestRecipe)
     # MANDATORY
@@ -350,11 +355,6 @@ http_response = plan.request(
     # You can chain this call with assert to check codes after request is done.
     # OPTIONAL (defaults to False)
     skip_code_check = false,
-    
-    # A service name designating a service that already exists inside the enclave
-    # If it does not, a validation error will be thrown
-    # MANDATORY
-    service_name = "my_service",
 )
 plan.print(get_response["body"]) # Prints the body of the request
 plan.print(get_response["code"]) # Prints the result code of the request (e.g. 200, 500)
@@ -558,6 +558,11 @@ If it succeeds, it returns a [future references][future-references-reference] wi
 ```python
 # This fails in runtime if response["code"] != 200 for each request in a 5 minute time span
 response = plan.wait(
+    # A Service name designating a service that already exists inside the enclave
+    # If it does not, a validation error will be thrown
+    # MANDATORY
+    service_name = "example-datastore-server-1",
+    
     # The recipe that will be run until assert passes.
     # Valid values are of the following types: (ExecRecipe, GetHttpRequestRecipe, PostHttpRequestRecipe)
     # MANDATORY
@@ -587,11 +592,6 @@ response = plan.wait(
     # Follows Go "time.Duration" format https://pkg.go.dev/time#ParseDuration
     # OPTIONAL (Default: "10s")
     timeout = "5m",
-
-    # A Service name designating a service that already exists inside the enclave
-    # If it does not, a validation error will be thrown
-    # MANDATORY
-    service_name = "example-datastore-server-1",
 )
 # If this point of the code is reached, the assertion has passed therefore the print statement will print "200"
 plan.print(response["code"])


Test patch:
diff --git a/cli/cli/command_framework/lowlevel/lowlevel_kurtosis_command_test.go b/cli/cli/main_test.go
similarity index 98%
rename from cli/cli/command_framework/lowlevel/lowlevel_kurtosis_command_test.go
rename to cli/cli/main_test.go
index 0d0262a18..bd191f6af 100644
--- a/cli/cli/command_framework/lowlevel/lowlevel_kurtosis_command_test.go
+++ b/cli/cli/main_test.go
@@ -1,4 +1,4 @@
-package lowlevel
+package main
 
 import (
 	"github.com/kurtosis-tech/stacktrace"
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/exec_framework_test_case_1_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/exec_framework_test_case_1_test.go
index ffe48df85..0b3796978 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/exec_framework_test_case_1_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/exec_framework_test_case_1_test.go
@@ -50,7 +50,7 @@ func (t execTestCase1) GetInstruction() *kurtosis_plan_instruction.KurtosisPlanI
 
 func (t execTestCase1) GetStarlarkCode() string {
 	recipe := `ExecRecipe(command=["mkdir", "-p", "/tmp/store"])`
-	return fmt.Sprintf("%s(%s=%s, %s=%q)", exec.ExecBuiltinName, exec.RecipeArgName, recipe, exec.ServiceNameArgName, execServiceName)
+	return fmt.Sprintf("%s(%s=%q, %s=%s)", exec.ExecBuiltinName, exec.ServiceNameArgName, execServiceName, exec.RecipeArgName, recipe)
 }
 
 func (t *execTestCase1) GetStarlarkCodeForAssertion() string {
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/exec_framework_test_case_2_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/exec_framework_test_case_2_test.go
index 0bd6e1ca7..c765a7a2e 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/exec_framework_test_case_2_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/exec_framework_test_case_2_test.go
@@ -46,12 +46,12 @@ func (t execTestCase2) GetInstruction() *kurtosis_plan_instruction.KurtosisPlanI
 
 func (t execTestCase2) GetStarlarkCode() string {
 	recipe := `ExecRecipe(command=["mkdir", "-p", "/tmp/store"])`
-	return fmt.Sprintf("%s(%s, %q)", exec.ExecBuiltinName, recipe, execServiceName)
+	return fmt.Sprintf("%s(%q, %s)", exec.ExecBuiltinName, execServiceName, recipe)
 }
 
 func (t *execTestCase2) GetStarlarkCodeForAssertion() string {
 	recipe := `ExecRecipe(command=["mkdir", "-p", "/tmp/store"])`
-	return fmt.Sprintf("%s(%s=%s, %s=%q)", exec.ExecBuiltinName, exec.RecipeArgName, recipe, exec.ServiceNameArgName, execServiceName)
+	return fmt.Sprintf("%s(%s=%q, %s=%s)", exec.ExecBuiltinName, exec.ServiceNameArgName, execServiceName, exec.RecipeArgName, recipe)
 }
 
 func (t execTestCase2) Assert(interpretationResult starlark.Value, executionResult *string) {
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/request_framework_test_case_1_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/request_framework_test_case_1_test.go
index 246405ab9..18b507fee 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/request_framework_test_case_1_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/request_framework_test_case_1_test.go
@@ -78,7 +78,7 @@ func (t *requestTestCase1) GetInstruction() *kurtosis_plan_instruction.KurtosisP
 
 func (t *requestTestCase1) GetStarlarkCode() string {
 	recipe := fmt.Sprintf(`GetHttpRequestRecipe(port_id=%q, endpoint=%q, extract={"key": ".value"})`, requestPortId, requestEndpoint)
-	return fmt.Sprintf("%s(%s=%s, %s=%q)", request.RequestBuiltinName, request.RecipeArgName, recipe, request.ServiceNameArgName, requestTestCaseServiceName)
+	return fmt.Sprintf("%s(%s=%q, %s=%s)", request.RequestBuiltinName, request.ServiceNameArgName, requestTestCaseServiceName, request.RecipeArgName, recipe)
 }
 
 func (t *requestTestCase1) GetStarlarkCodeForAssertion() string {
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/request_framework_test_case_2_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/request_framework_test_case_2_test.go
index 05db441ef..b88afae2d 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/request_framework_test_case_2_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/request_framework_test_case_2_test.go
@@ -67,12 +67,12 @@ func (t *requestTestCase2) GetInstruction() *kurtosis_plan_instruction.KurtosisP
 
 func (t *requestTestCase2) GetStarlarkCode() string {
 	recipe := fmt.Sprintf(`GetHttpRequestRecipe(port_id=%q, endpoint=%q, extract={"key": ".value"})`, requestPortId, requestEndpoint)
-	return fmt.Sprintf("%s(%s, %q)", request.RequestBuiltinName, recipe, requestTestCaseServiceName)
+	return fmt.Sprintf("%s(%q, %s)", request.RequestBuiltinName, requestTestCaseServiceName, recipe)
 }
 
 func (t *requestTestCase2) GetStarlarkCodeForAssertion() string {
 	recipe := fmt.Sprintf(`GetHttpRequestRecipe(port_id=%q, endpoint=%q, extract={"key": ".value"})`, requestPortId, requestEndpoint)
-	return fmt.Sprintf("%s(%s=%s, %s=%q)", request.RequestBuiltinName, request.RecipeArgName, recipe, request.ServiceNameArgName, requestTestCaseServiceName)
+	return fmt.Sprintf("%s(%s=%q, %s=%s)", request.RequestBuiltinName, request.ServiceNameArgName, requestTestCaseServiceName, request.RecipeArgName, recipe)
 }
 
 func (t *requestTestCase2) Assert(interpretationResult starlark.Value, executionResult *string) {
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/wait_framework_test_case_1_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/wait_framework_test_case_1_test.go
index 4e725cf98..16dc8a266 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/wait_framework_test_case_1_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/wait_framework_test_case_1_test.go
@@ -84,7 +84,7 @@ func (t *waitTestCase1) GetInstruction() *kurtosis_plan_instruction.KurtosisPlan
 
 func (t *waitTestCase1) GetStarlarkCode() string {
 	recipeStr := fmt.Sprintf(`PostHttpRequestRecipe(port_id=%q, endpoint=%q, body=%q, content_type=%q, extract={"key": ".value"})`, waitRecipePortId, waitRecipeEndpoint, waitRecipeBody, waitRecipeContentType)
-	return fmt.Sprintf("%s(%s=%s, %s=%q, %s=%q, %s=%s, %s=%q, %s=%q, %s=%q)", wait.WaitBuiltinName, wait.RecipeArgName, recipeStr, wait.ValueFieldArgName, waitValueField, wait.AssertionArgName, waitAssertion, wait.TargetArgName, waitTargetValue, wait.IntervalArgName, waitInterval, wait.TimeoutArgName, waitTimeout, wait.ServiceNameArgName, waitRecipeTestCaseServiceName)
+	return fmt.Sprintf("%s(%s=%q, %s=%s, %s=%q, %s=%q, %s=%s, %s=%q, %s=%q)", wait.WaitBuiltinName, wait.ServiceNameArgName, waitRecipeTestCaseServiceName, wait.RecipeArgName, recipeStr, wait.ValueFieldArgName, waitValueField, wait.AssertionArgName, waitAssertion, wait.TargetArgName, waitTargetValue, wait.IntervalArgName, waitInterval, wait.TimeoutArgName, waitTimeout)
 }
 
 func (t *waitTestCase1) GetStarlarkCodeForAssertion() string {
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/wait_framework_test_case_2_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/wait_framework_test_case_2_test.go
index 295409d7d..169654ef1 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/wait_framework_test_case_2_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/wait_framework_test_case_2_test.go
@@ -68,12 +68,12 @@ func (t *waitTestCase2) GetInstruction() *kurtosis_plan_instruction.KurtosisPlan
 
 func (t *waitTestCase2) GetStarlarkCode() string {
 	recipeStr := fmt.Sprintf(`PostHttpRequestRecipe(port_id=%q, endpoint=%q, body=%q, content_type=%q, extract={"key": ".value"})`, waitRecipePortId, waitRecipeEndpoint, waitRecipeBody, waitRecipeContentType)
-	return fmt.Sprintf("%s(%s, %q, %q, %s, %q, %q, %q)", wait.WaitBuiltinName, recipeStr, waitValueField, waitAssertion, waitTargetValue, waitInterval, waitTimeout, waitRecipeTestCaseServiceName)
+	return fmt.Sprintf("%s(%q, %s, %q, %q, %s, %q, %q)", wait.WaitBuiltinName, waitRecipeTestCaseServiceName, recipeStr, waitValueField, waitAssertion, waitTargetValue, waitInterval, waitTimeout)
 }
 
 func (t *waitTestCase2) GetStarlarkCodeForAssertion() string {
 	recipeStr := fmt.Sprintf(`PostHttpRequestRecipe(port_id=%q, endpoint=%q, body=%q, content_type=%q, extract={"key": ".value"})`, waitRecipePortId, waitRecipeEndpoint, waitRecipeBody, waitRecipeContentType)
-	return fmt.Sprintf("%s(%s=%s, %s=%q, %s=%q, %s=%s, %s=%q, %s=%q, %s=%q)", wait.WaitBuiltinName, wait.RecipeArgName, recipeStr, wait.ValueFieldArgName, waitValueField, wait.AssertionArgName, waitAssertion, wait.TargetArgName, waitTargetValue, wait.IntervalArgName, waitInterval, wait.TimeoutArgName, waitTimeout, wait.ServiceNameArgName, waitRecipeTestCaseServiceName)
+	return fmt.Sprintf("%s(%s=%q, %s=%s, %s=%q, %s=%q, %s=%s, %s=%q, %s=%q)", wait.WaitBuiltinName, wait.ServiceNameArgName, waitRecipeTestCaseServiceName, wait.RecipeArgName, recipeStr, wait.ValueFieldArgName, waitValueField, wait.AssertionArgName, waitAssertion, wait.TargetArgName, waitTargetValue, wait.IntervalArgName, waitInterval, wait.TimeoutArgName, waitTimeout)
 }
 
 func (t *waitTestCase2) Assert(interpretationResult starlark.Value, executionResult *string) {