Repository: kurtosis-tech/kurtosis (go)

Issue:
Block absolute imports for local imports
### Background & motivation

Right now we allow absolute imports for specifying local imports (imports within a package). This is a legacy from the days before we had relative imports, and it’s causing some of the painpoints above.

We should instead ban absolute imports within a package, and force relative imports (either via a leading `.` or from the package root using `/` )


from: https://www.notion.so/kurtosistech/2023-09-Forked-Packages-Cleanup-d8bc4f5165ae4b039c07cdad56892459



### Desired behavior

This has three benefits:

- Users don’t have the option to get confused about which syntax they should use
- Eliminate the “accidentally pull from Github when I didn’t want to” issue
- Make it clearer at a glance which imports are imported from outside the package, and which imports are imported from inside


### How important is this to you?

Painful; the lack of this feature makes using Kurtosis frictionful.

Pull request:
feat!: block 'local absolute locators', users should replace' local absolute locators' with 'relative locators'
## Description:
block 'local absolute locators', users should replace' local absolute locators' with 'relative locators'

## Is this change user facing?
YES

## References (if applicable):
This should be merged after https://github.com/kurtosis-tech/kurtosis/pull/1427
Fix #1435 


Patch:
diff --git a/core/server/api_container/server/startosis_engine/builtins/import_module/import_module.go b/core/server/api_container/server/startosis_engine/builtins/import_module/import_module.go
index 1af3aca15..d38872bc1 100644
--- a/core/server/api_container/server/startosis_engine/builtins/import_module/import_module.go
+++ b/core/server/api_container/server/startosis_engine/builtins/import_module/import_module.go
@@ -4,7 +4,6 @@ import (
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_helper"
-	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/starlark_warning"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages"
 	"go.starlark.net/starlark"
@@ -47,23 +46,8 @@ func NewImportModule(
 					IsOptional:        false,
 					ZeroValueProvider: builtin_argument.ZeroValueProvider[starlark.String],
 					Validator: func(value starlark.Value) *startosis_errors.InterpretationError {
-						return builtin_argument.NonEmptyString(value, ModuleFileArgName)
+						return builtin_argument.RelativeOrRemoteAbsoluteLocator(value, packageId, ModuleFileArgName)
 					},
-					//TODO remove this deprecation warning when the local absolute locators block is implemented
-					Deprecation: starlark_warning.Deprecation(
-						starlark_warning.DeprecationDate{
-							Day: 0, Year: 0, Month: 0, //nolint:gomnd
-
-						},
-						"Local 'absolute locators' are being deprecated in favor of 'relative locators' to normalize when a locator is pointing to inside or outside the package. e.g.: if your package name is 'github.com/sample/sample-kurtosis-package' and the package contains a 'local absolute locator' for example 'github.com/sample/sample-kurtosis-package/component/component.star' it should be modified to a relative version like this '/component/component.star' or './component/component.star', or, if you are referencing it in a sub-folder, you can use a 'relative locator' like this '../component/component.star'.",
-						func(value starlark.Value) bool {
-							// err means that it is a local absolute locator
-							if err := builtin_argument.RelativeOrRemoteAbsoluteLocator(value, packageId, ModuleFileArgName); err != nil {
-								return true
-							}
-							return false
-						},
-					),
 				},
 			},
 		},
diff --git a/core/server/api_container/server/startosis_engine/builtins/read_file/read_file.go b/core/server/api_container/server/startosis_engine/builtins/read_file/read_file.go
index 9e35491e1..cac685ebe 100644
--- a/core/server/api_container/server/startosis_engine/builtins/read_file/read_file.go
+++ b/core/server/api_container/server/startosis_engine/builtins/read_file/read_file.go
@@ -4,7 +4,6 @@ import (
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_helper"
-	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/starlark_warning"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages"
 	"go.starlark.net/starlark"
@@ -26,21 +25,8 @@ func NewReadFileHelper(packageId string, packageContentProvider startosis_packag
 					IsOptional:        false,
 					ZeroValueProvider: builtin_argument.ZeroValueProvider[starlark.String],
 					Validator: func(value starlark.Value) *startosis_errors.InterpretationError {
-						return builtin_argument.NonEmptyString(value, SrcArgName)
+						return builtin_argument.RelativeOrRemoteAbsoluteLocator(value, packageId, SrcArgName)
 					},
-					//TODO remove this deprecation warning when the local absolute locators block is implemented
-					Deprecation: starlark_warning.Deprecation(
-						starlark_warning.DeprecationDate{
-							Day: 0, Year: 0, Month: 0, //nolint:gomnd
-						},
-						"Local 'absolute locators' are being deprecated in favor of 'relative locators' to normalize when a locator is pointing to inside or outside the package. e.g.: if your package name is 'github.com/sample/sample-kurtosis-package' and the package contains a 'local absolute locator' for example 'github.com/sample/sample-kurtosis-package/component/component.star' it should be modified to a relative version like this '/component/component.star' or './component/component.star', or, if you are referencing it in a sub-folder, you can use a 'relative locator' like this '../component/component.star'.",
-						func(value starlark.Value) bool {
-							if err := builtin_argument.RelativeOrRemoteAbsoluteLocator(value, packageId, SrcArgName); err != nil {
-								return true
-							}
-							return false
-						},
-					),
 				},
 			},
 		},
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go
index 1b0f482ac..160bb1e5d 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go
@@ -11,7 +11,6 @@ import (
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction"
-	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/starlark_warning"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator"
@@ -41,20 +40,9 @@ func NewUploadFiles(packageId string, serviceNetwork service_network.ServiceNetw
 					Name:              SrcArgName,
 					IsOptional:        false,
 					ZeroValueProvider: builtin_argument.ZeroValueProvider[starlark.String],
-					Validator:         nil,
-					//TODO remove this deprecation warning when the local absolute locators block is implemented
-					Deprecation: starlark_warning.Deprecation(
-						starlark_warning.DeprecationDate{
-							Day: 0, Year: 0, Month: 0, //nolint:gomnd
-						},
-						"Local 'absolute locators' are being deprecated in favor of 'relative locators' to normalize when a locator is pointing to inside or outside the package. e.g.: if your package name is 'github.com/sample/sample-kurtosis-package' and the package contains a 'local absolute locator' for example 'github.com/sample/sample-kurtosis-package/component/component.star' it should be modified to a relative version like this '/component/component.star' or './component/component.star', or, if you are referencing it in a sub-folder, you can use a 'relative locator' like this '../component/component.star'.",
-						func(value starlark.Value) bool {
-							if err := builtin_argument.RelativeOrRemoteAbsoluteLocator(value, packageId, SrcArgName); err != nil {
-								return true
-							}
-							return false
-						},
-					),
+					Validator: func(value starlark.Value) *startosis_errors.InterpretationError {
+						return builtin_argument.RelativeOrRemoteAbsoluteLocator(value, packageId, SrcArgName)
+					},
 				},
 				{
 					Name:              ArtifactNameArgName,
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument/validators.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument/validators.go
index 0f9f11f60..8f12e8abd 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument/validators.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument/validators.go
@@ -113,6 +113,10 @@ func DurationOrNone(value starlark.Value, attributeName string) *startosis_error
 
 func RelativeOrRemoteAbsoluteLocator(locatorStarlarkValue starlark.Value, packageId string, argNameForLogging string) *startosis_errors.InterpretationError {
 
+	if err := NonEmptyString(locatorStarlarkValue, argNameForLogging); err != nil {
+		return err
+	}
+
 	locatorStarlarkStr, ok := locatorStarlarkValue.(starlark.String)
 	if !ok {
 		return startosis_errors.NewInterpretationError("Value for '%s' was expected to be a starlark.String but was '%s'", argNameForLogging, reflect.TypeOf(locatorStarlarkValue))
diff --git a/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider/mock_package_content_provider.go b/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider/mock_package_content_provider.go
index 3a0ca86d3..a4320675a 100644
--- a/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider/mock_package_content_provider.go
+++ b/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider/mock_package_content_provider.go
@@ -21,11 +21,13 @@ const (
 // TODO: use the mockery-generated mock: startosis_package.MockPackageContentProvider
 type MockPackageContentProvider struct {
 	starlarkPackages map[string]string
+	packageId        string
 }
 
 func NewMockPackageContentProvider() *MockPackageContentProvider {
 	return &MockPackageContentProvider{
 		starlarkPackages: make(map[string]string),
+		packageId:        "",
 	}
 }
 
@@ -69,8 +71,7 @@ func (provider *MockPackageContentProvider) GetAbsoluteLocatorForRelativeModuleL
 	if strings.HasPrefix(relativeOrAbsoluteModulePath, startosis_constants.GithubDomainPrefix) {
 		return relativeOrAbsoluteModulePath, nil
 	}
-	// TODO implement properly so that it works with relative paths
-	return "", nil
+	return provider.packageId, nil
 }
 
 func (provider *MockPackageContentProvider) AddFileContent(packageId string, contents string) error {
@@ -79,6 +80,7 @@ func (provider *MockPackageContentProvider) AddFileContent(packageId string, con
 		return stacktrace.Propagate(err, "Error writing content to temporary file")
 	}
 	provider.starlarkPackages[packageId] = absFilePath
+	provider.packageId = packageId
 	return nil
 }
 


Test patch:
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/import_module_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/import_module_framework_test.go
index 4cfac143d..947b45b4b 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/import_module_framework_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/import_module_framework_test.go
@@ -39,7 +39,7 @@ func (suite *KurtosisHelperTestSuite) TestImportFile() {
 	moduleGlobalCache := map[string]*startosis_packages.ModuleCacheEntry{}
 
 	suite.packageContentProvider.EXPECT().GetModuleContents(TestModuleFileName).Return("Hello World!", nil)
-	suite.packageContentProvider.EXPECT().GetAbsoluteLocatorForRelativeModuleLocator(startosis_constants.PackageIdPlaceholderForStandaloneScript, TestModuleFileName).Return(TestModuleFileName, nil)
+	suite.packageContentProvider.EXPECT().GetAbsoluteLocatorForRelativeModuleLocator(startosis_constants.PackageIdPlaceholderForStandaloneScript, TestModuleRelativeLocator).Return(TestModuleFileName, nil)
 
 	suite.run(&importModuleTestCase{
 		T:                      suite.T(),
@@ -52,11 +52,11 @@ func (t *importModuleTestCase) GetHelper() *kurtosis_helper.KurtosisHelper {
 	recursiveInterpret := func(moduleId string, scriptContent string) (starlark.StringDict, *startosis_errors.InterpretationError) {
 		return importModule_mockStarlarkModule.Members, nil
 	}
-	return import_module.NewImportModule("", recursiveInterpret, t.packageContentProvider, t.moduleGlobalCache)
+	return import_module.NewImportModule(TestModulePackageId, recursiveInterpret, t.packageContentProvider, t.moduleGlobalCache)
 }
 
 func (t *importModuleTestCase) GetStarlarkCode() string {
-	return fmt.Sprintf("%s(%s=%q)", import_module.ImportModuleBuiltinName, import_module.ModuleFileArgName, TestModuleFileName)
+	return fmt.Sprintf("%s(%s=%q)", import_module.ImportModuleBuiltinName, import_module.ModuleFileArgName, TestModuleRelativeLocator)
 }
 
 func (t *importModuleTestCase) GetStarlarkCodeForAssertion() string {
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/import_module_with_local_absolute_locator_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/import_module_with_local_absolute_locator_framework_test.go
new file mode 100644
index 000000000..02b24761c
--- /dev/null
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/import_module_with_local_absolute_locator_framework_test.go
@@ -0,0 +1,65 @@
+package test_engine
+
+import (
+	"fmt"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/builtins/import_module"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_helper"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages"
+	"go.starlark.net/starlark"
+	"go.starlark.net/starlarkstruct"
+	"testing"
+)
+
+const (
+	importModuleWithLocalAbsoluteLocatorExpectedErrorMsg = "Cannot construct 'import_module' from the provided arguments.\n\tCaused by: The following argument(s) could not be parsed or did not pass validation: {\"module_file\":\"The locator '\\\"github.com/kurtosistech/test-package/helpers.star\\\"' set in attribute 'module_file' is not a 'local relative locator'. Local absolute locators are not allowed you should modified it to be a valid 'local relative locator'\"}"
+)
+
+var (
+	importModuleWithLocalAbsoluteLocator_mockStarlarkModule = &starlarkstruct.Module{
+		Name: TestModuleFileName,
+		Members: starlark.StringDict{
+			importModule_moduleConstKey: starlark.String("Hello World!"),
+		},
+	}
+)
+
+type importModuleWithLocalAbsoluteLocatorTestCase struct {
+	*testing.T
+
+	// store the cache inside the test object such that we can check its state in Assert()
+	moduleGlobalCache      map[string]*startosis_packages.ModuleCacheEntry
+	packageContentProvider startosis_packages.PackageContentProvider
+}
+
+func (suite *KurtosisHelperTestSuite) TestImportFileWithLocalAbsoluteLocatorShouldNotBeValid() {
+	// start with an empty cache to validate it gets populated
+	moduleGlobalCache := map[string]*startosis_packages.ModuleCacheEntry{}
+
+	suite.runShouldFail(
+		&importModuleWithLocalAbsoluteLocatorTestCase{
+			T:                      suite.T(),
+			moduleGlobalCache:      moduleGlobalCache,
+			packageContentProvider: suite.packageContentProvider,
+		},
+		importModuleWithLocalAbsoluteLocatorExpectedErrorMsg,
+	)
+}
+
+func (t *importModuleWithLocalAbsoluteLocatorTestCase) GetHelper() *kurtosis_helper.KurtosisHelper {
+	recursiveInterpret := func(moduleId string, scriptContent string) (starlark.StringDict, *startosis_errors.InterpretationError) {
+		return importModuleWithLocalAbsoluteLocator_mockStarlarkModule.Members, nil
+	}
+	return import_module.NewImportModule(TestModulePackageId, recursiveInterpret, t.packageContentProvider, t.moduleGlobalCache)
+}
+
+func (t *importModuleWithLocalAbsoluteLocatorTestCase) GetStarlarkCode() string {
+	return fmt.Sprintf("%s(%s=%q)", import_module.ImportModuleBuiltinName, import_module.ModuleFileArgName, TestModuleFileName)
+}
+
+func (t *importModuleWithLocalAbsoluteLocatorTestCase) GetStarlarkCodeForAssertion() string {
+	return ""
+}
+
+func (t *importModuleWithLocalAbsoluteLocatorTestCase) Assert(_ starlark.Value) {
+}
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/read_file_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/read_file_framework_test.go
index c7c729f9b..4c060ab8e 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/read_file_framework_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/read_file_framework_test.go
@@ -18,7 +18,7 @@ type readFileTestCase struct {
 }
 
 func (suite *KurtosisHelperTestSuite) TestReadFile() {
-	suite.packageContentProvider.EXPECT().GetAbsoluteLocatorForRelativeModuleLocator(startosis_constants.PackageIdPlaceholderForStandaloneScript, TestModuleFileName).Return(TestModuleFileName, nil)
+	suite.packageContentProvider.EXPECT().GetAbsoluteLocatorForRelativeModuleLocator(startosis_constants.PackageIdPlaceholderForStandaloneScript, TestModuleRelativeLocator).Return(TestModuleFileName, nil)
 	suite.packageContentProvider.EXPECT().GetModuleContents(TestModuleFileName).Return("Hello World!", nil)
 
 	suite.run(&readFileTestCase{
@@ -28,11 +28,11 @@ func (suite *KurtosisHelperTestSuite) TestReadFile() {
 }
 
 func (t *readFileTestCase) GetHelper() *kurtosis_helper.KurtosisHelper {
-	return read_file.NewReadFileHelper("", t.packageContentProvider)
+	return read_file.NewReadFileHelper(TestModulePackageId, t.packageContentProvider)
 }
 
 func (t *readFileTestCase) GetStarlarkCode() string {
-	return fmt.Sprintf(`%s(%s=%q)`, read_file.ReadFileBuiltinName, read_file.SrcArgName, TestModuleFileName)
+	return fmt.Sprintf(`%s(%s=%q)`, read_file.ReadFileBuiltinName, read_file.SrcArgName, TestModuleRelativeLocator)
 }
 
 func (t *readFileTestCase) GetStarlarkCodeForAssertion() string {
@@ -40,7 +40,7 @@ func (t *readFileTestCase) GetStarlarkCodeForAssertion() string {
 }
 
 func (t *readFileTestCase) Assert(result starlark.Value) {
-	t.packageContentProvider.AssertCalled(t, "GetAbsoluteLocatorForRelativeModuleLocator", startosis_constants.PackageIdPlaceholderForStandaloneScript, TestModuleFileName)
+	t.packageContentProvider.AssertCalled(t, "GetAbsoluteLocatorForRelativeModuleLocator", startosis_constants.PackageIdPlaceholderForStandaloneScript, TestModuleRelativeLocator)
 	t.packageContentProvider.AssertCalled(t, "GetModuleContents", TestModuleFileName)
 	require.Equal(t, result, starlark.String("Hello World!"))
 }
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/read_file_with_local_absolute_locator_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/read_file_with_local_absolute_locator_framework_test.go
new file mode 100644
index 000000000..ed5a33262
--- /dev/null
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/read_file_with_local_absolute_locator_framework_test.go
@@ -0,0 +1,47 @@
+package test_engine
+
+import (
+	"fmt"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/builtins/read_file"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_helper"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages"
+	"go.starlark.net/starlark"
+	"testing"
+)
+
+const (
+	readFileWithLocalAbsoluteLocatorExpectedErrorMsg = "Cannot construct 'read_file' from the provided arguments.\n\tCaused by: The following argument(s) could not be parsed or did not pass validation: {\"src\":\"The locator '\\\"github.com/kurtosistech/test-package/helpers.star\\\"' set in attribute 'src' is not a 'local relative locator'. Local absolute locators are not allowed you should modified it to be a valid 'local relative locator'\"}"
+)
+
+type readFileWithLocalAbsoluteLocatorTestCase struct {
+	*testing.T
+
+	packageContentProvider *startosis_packages.MockPackageContentProvider
+}
+
+func (suite *KurtosisHelperTestSuite) TestReadFileWithLocalAbsoluteLocatorShouldNotBeValid() {
+
+	suite.runShouldFail(
+		&readFileWithLocalAbsoluteLocatorTestCase{
+			T:                      suite.T(),
+			packageContentProvider: suite.packageContentProvider,
+		},
+		readFileWithLocalAbsoluteLocatorExpectedErrorMsg,
+	)
+}
+
+func (t *readFileWithLocalAbsoluteLocatorTestCase) GetHelper() *kurtosis_helper.KurtosisHelper {
+	return read_file.NewReadFileHelper(TestModulePackageId, t.packageContentProvider)
+}
+
+func (t *readFileWithLocalAbsoluteLocatorTestCase) GetStarlarkCode() string {
+	return fmt.Sprintf(`%s(%s=%q)`, read_file.ReadFileBuiltinName, read_file.SrcArgName, TestModuleFileName)
+}
+
+func (t *readFileWithLocalAbsoluteLocatorTestCase) GetStarlarkCodeForAssertion() string {
+	return ""
+}
+
+func (t *readFileWithLocalAbsoluteLocatorTestCase) Assert(_ starlark.Value) {
+
+}
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/static_constants.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/static_constants.go
index 6a9799f90..f09444e47 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/static_constants.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/static_constants.go
@@ -21,7 +21,10 @@ var (
 
 	TestSrcPath = "/path/to/file.txt"
 
-	TestModuleFileName = "github.com/kurtosistech/test-package/helpers.star"
+	TestModulePackageId       = "github.com/kurtosistech/test-package"
+	TestModuleFileName        = "github.com/kurtosistech/test-package/helpers.star"
+	TestModuleRelativeLocator = "./helpers.star"
+	TestModuleDirpath         = "/kurtosistech/test-package"
 
 	TestContainerImageName = "kurtosistech/example-datastore-server"
 
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/suite_kurtosis_helper_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/suite_kurtosis_helper_test.go
index 91f71150a..ea4ad16d9 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/suite_kurtosis_helper_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/suite_kurtosis_helper_test.go
@@ -44,3 +44,14 @@ func (suite *KurtosisHelperTestSuite) run(builtin KurtosisHelperBaseTest) {
 
 	builtin.Assert(result)
 }
+
+func (suite *KurtosisHelperTestSuite) runShouldFail(builtin KurtosisHelperBaseTest, expectedErrMsg string) {
+	// Add the KurtosisPlanInstruction that is being tested
+	helper := builtin.GetHelper()
+	suite.starlarkEnv[helper.GetName()] = starlark.NewBuiltin(helper.GetName(), helper.CreateBuiltin())
+
+	starlarkCode := builtin.GetStarlarkCode()
+	_, err := starlark.ExecFile(suite.starlarkThread, startosis_constants.PackageIdPlaceholderForStandaloneScript, codeToExecute(starlarkCode), suite.starlarkEnv)
+	suite.Require().Error(err, "Expected to fail running starlark code %s, but it didn't fail", builtin.GetStarlarkCode())
+	suite.Require().Equal(expectedErrMsg, err.Error())
+}
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/suite_kurtosis_plan_instruction_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/suite_kurtosis_plan_instruction_test.go
index c5996d62c..2d6bc4c25 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/suite_kurtosis_plan_instruction_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/suite_kurtosis_plan_instruction_test.go
@@ -85,3 +85,19 @@ func (suite *KurtosisPlanInstructionTestSuite) run(builtin KurtosisPlanInstructi
 
 	suite.Require().Equal(starlarkCodeForAssertion, serializedInstruction)
 }
+
+func (suite *KurtosisPlanInstructionTestSuite) runShouldFail(builtin KurtosisPlanInstructionBaseTest, expectedErrMsg string) {
+	instructionsPlan := instructions_plan.NewInstructionsPlan()
+
+	// Add the KurtosisPlanInstruction that is being tested
+	instructionFromBuiltin := builtin.GetInstruction()
+	emptyEnclaveComponents := enclave_structure.NewEnclaveComponents()
+	emptyInstructionsPlanMask := resolver.NewInstructionsPlanMask(0)
+	instructionWrapper := kurtosis_plan_instruction.NewKurtosisPlanInstructionWrapper(instructionFromBuiltin, emptyEnclaveComponents, nil, emptyInstructionsPlanMask, instructionsPlan)
+	suite.starlarkEnv[instructionWrapper.GetName()] = starlark.NewBuiltin(instructionWrapper.GetName(), instructionWrapper.CreateBuiltin())
+
+	starlarkCode := builtin.GetStarlarkCode()
+	_, err := starlark.ExecFile(suite.starlarkThread, startosis_constants.PackageIdPlaceholderForStandaloneScript, codeToExecute(starlarkCode), suite.starlarkEnv)
+	suite.Require().Error(err, "Expected to fail running starlark code %s, but it didn't fail", builtin.GetStarlarkCode())
+	suite.Require().Equal(expectedErrMsg, err.Error())
+}
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_framework_test.go
index fc767972f..a57a741b1 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_framework_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_framework_test.go
@@ -47,11 +47,11 @@ func (suite *KurtosisPlanInstructionTestSuite) TestUploadFiles() {
 }
 
 func (t *uploadFilesTestCase) GetInstruction() *kurtosis_plan_instruction.KurtosisPlanInstruction {
-	return upload_files.NewUploadFiles("", t.serviceNetwork, t.packageContentProvider)
+	return upload_files.NewUploadFiles(TestModulePackageId, t.serviceNetwork, t.packageContentProvider)
 }
 
 func (t *uploadFilesTestCase) GetStarlarkCode() string {
-	return fmt.Sprintf("%s(%s=%q, %s=%q)", upload_files.UploadFilesBuiltinName, upload_files.SrcArgName, TestModuleFileName, upload_files.ArtifactNameArgName, TestArtifactName)
+	return fmt.Sprintf("%s(%s=%q, %s=%q)", upload_files.UploadFilesBuiltinName, upload_files.SrcArgName, TestModuleRelativeLocator, upload_files.ArtifactNameArgName, TestArtifactName)
 }
 
 func (t *uploadFilesTestCase) GetStarlarkCodeForAssertion() string {
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_update_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_update_framework_test.go
index 151706676..58257b24a 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_update_framework_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_update_framework_test.go
@@ -45,11 +45,11 @@ func (suite *KurtosisPlanInstructionTestSuite) TestUploadFilesUpdate() {
 }
 
 func (t *uploadFilesUpdateTestCase) GetInstruction() *kurtosis_plan_instruction.KurtosisPlanInstruction {
-	return upload_files.NewUploadFiles("", t.serviceNetwork, t.packageContentProvider)
+	return upload_files.NewUploadFiles(TestModulePackageId, t.serviceNetwork, t.packageContentProvider)
 }
 
 func (t *uploadFilesUpdateTestCase) GetStarlarkCode() string {
-	return fmt.Sprintf("%s(%s=%q, %s=%q)", upload_files.UploadFilesBuiltinName, upload_files.SrcArgName, TestModuleFileName, upload_files.ArtifactNameArgName, TestArtifactName)
+	return fmt.Sprintf("%s(%s=%q, %s=%q)", upload_files.UploadFilesBuiltinName, upload_files.SrcArgName, TestModuleRelativeLocator, upload_files.ArtifactNameArgName, TestArtifactName)
 }
 
 func (t *uploadFilesUpdateTestCase) GetStarlarkCodeForAssertion() string {
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_with_local_absolute_locator_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_with_local_absolute_locator_framework_test.go
new file mode 100644
index 000000000..fb1504461
--- /dev/null
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_with_local_absolute_locator_framework_test.go
@@ -0,0 +1,50 @@
+package test_engine
+
+import (
+	"fmt"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages"
+	"go.starlark.net/starlark"
+	"testing"
+)
+
+const (
+	uploadFilesWithLocalAbsoluteLocatorExpectedErrorMsg = "Cannot construct 'upload_files' from the provided arguments.\n\tCaused by: The following argument(s) could not be parsed or did not pass validation: {\"src\":\"The locator '\\\"github.com/kurtosistech/test-package/helpers.star\\\"' set in attribute 'src' is not a 'local relative locator'. Local absolute locators are not allowed you should modified it to be a valid 'local relative locator'\"}"
+)
+
+type uploadFilesWithLocalAbsoluteLocatorTestCase struct {
+	*testing.T
+	serviceNetwork         *service_network.MockServiceNetwork
+	packageContentProvider startosis_packages.PackageContentProvider
+}
+
+func (suite *KurtosisPlanInstructionTestSuite) TestUploadFilesWithLocalAbsoluteLocatorShouldNotBeValid() {
+	suite.Require().Nil(suite.packageContentProvider.AddFileContent(TestModuleFileName, "Hello World!"))
+
+	suite.runShouldFail(
+		&uploadFilesWithLocalAbsoluteLocatorTestCase{
+			T:                      suite.T(),
+			serviceNetwork:         suite.serviceNetwork,
+			packageContentProvider: suite.packageContentProvider,
+		},
+		uploadFilesWithLocalAbsoluteLocatorExpectedErrorMsg,
+	)
+}
+
+func (t *uploadFilesWithLocalAbsoluteLocatorTestCase) GetInstruction() *kurtosis_plan_instruction.KurtosisPlanInstruction {
+	return upload_files.NewUploadFiles(TestModulePackageId, t.serviceNetwork, t.packageContentProvider)
+}
+
+func (t *uploadFilesWithLocalAbsoluteLocatorTestCase) GetStarlarkCode() string {
+	return fmt.Sprintf("%s(%s=%q, %s=%q)", upload_files.UploadFilesBuiltinName, upload_files.SrcArgName, TestModuleFileName, upload_files.ArtifactNameArgName, TestArtifactName)
+}
+
+func (t *uploadFilesWithLocalAbsoluteLocatorTestCase) GetStarlarkCodeForAssertion() string {
+	return ""
+}
+
+func (t *uploadFilesWithLocalAbsoluteLocatorTestCase) Assert(interpretationResult starlark.Value, executionResult *string) {
+
+}
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_without_name_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_without_name_framework_test.go
index 0086fcacf..5bbdb3b15 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_without_name_framework_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/upload_files_without_name_framework_test.go
@@ -52,11 +52,11 @@ func (suite *KurtosisPlanInstructionTestSuite) TestUploadFilesWithoutName() {
 }
 
 func (t *uploadFilesWithoutNameTestCase) GetInstruction() *kurtosis_plan_instruction.KurtosisPlanInstruction {
-	return upload_files.NewUploadFiles("", t.serviceNetwork, t.packageContentProvider)
+	return upload_files.NewUploadFiles(TestModulePackageId, t.serviceNetwork, t.packageContentProvider)
 }
 
 func (t *uploadFilesWithoutNameTestCase) GetStarlarkCode() string {
-	return fmt.Sprintf("%s(%s=%q)", upload_files.UploadFilesBuiltinName, upload_files.SrcArgName, TestModuleFileName)
+	return fmt.Sprintf("%s(%s=%q)", upload_files.UploadFilesBuiltinName, upload_files.SrcArgName, TestModuleRelativeLocator)
 }
 
 func (t *uploadFilesWithoutNameTestCase) GetStarlarkCodeForAssertion() string {
diff --git a/internal_testsuites/starlark/no-run-in-main-star/main.star b/internal_testsuites/starlark/no-run-in-main-star/main.star
index 5d61667ae..54fcce3aa 100644
--- a/internal_testsuites/starlark/no-run-in-main-star/main.star
+++ b/internal_testsuites/starlark/no-run-in-main-star/main.star
@@ -1,1 +1,1 @@
-lib = import_module("github.com/kurtosis-tech/kurtosis/internal_testsuites/starlark/no-run-in-main-star/lib/lib.star")
+lib = import_module("./lib/lib.star")
diff --git a/internal_testsuites/starlark/upload-file-package/main.star b/internal_testsuites/starlark/upload-file-package/main.star
index 37c3b27ec..80536d348 100644
--- a/internal_testsuites/starlark/upload-file-package/main.star
+++ b/internal_testsuites/starlark/upload-file-package/main.star
@@ -3,7 +3,7 @@
 # named large-file.bin. This file is generated on the spot to avoid checking it into GitHub
 def run(plan, args):
     plan.print("Starting upload")
-    large_file_artifact_id = plan.upload_files("github.com/kurtosis-tech/kurtosis/internal_testsuites/starlark/upload-file-package/large-file.bin")
+    large_file_artifact_id = plan.upload_files("./large-file.bin")
 
     plan.print("Upload finished - Comparing file hash to parameter")
 
diff --git a/internal_testsuites/starlark/valid-kurtosis-package-with-input/main.star b/internal_testsuites/starlark/valid-kurtosis-package-with-input/main.star
index 395f90f0f..42c1c0573 100644
--- a/internal_testsuites/starlark/valid-kurtosis-package-with-input/main.star
+++ b/internal_testsuites/starlark/valid-kurtosis-package-with-input/main.star
@@ -1,4 +1,4 @@
-lib = import_module("github.com/kurtosis-tech/kurtosis/internal_testsuites/starlark/valid-kurtosis-package-with-input/lib/lib.star")
+lib = import_module("./lib/lib.star")
 
 
 def run(plan, args):