While trying to pass a long environment variable to a VM I found that it will crash immediately on startup if the env var is too long. If the value is 128 bytes it works, but around 1500 bytes it crashes.
These tests demonstrate the issue:
func TestEnvVar(t *testing.T) {
var (
shortEnvVar = strings.Repeat("x", 128)
longEnvVar = strings.Repeat("x", 1500)
)
t.Run("long", func(t *testing.T) {
_, err := msb.CreateSandbox(
t.Context(),
"a134f2dc-1719-45e1-b04f-f79deb4918ae",
msb.WithCPUs(2),
msb.WithMemory(1024),
msb.WithImage("alpine"),
msb.WithHostname("alpine"),
msb.WithEnv(map[string]string{
"x": longEnvVar,
}),
msb.WithReplace(),
)
if err != nil {
t.Error("sandbox creation failed:", err)
}
})
t.Run("short", func(t *testing.T) {
_, err := msb.CreateSandbox(
t.Context(),
"a134f2dc-1719-45e1-b04f-f79deb4918ae",
msb.WithCPUs(2),
msb.WithMemory(1024),
msb.WithImage("alpine"),
msb.WithHostname("alpine"),
msb.WithEnv(map[string]string{
"x": shortEnvVar,
}),
msb.WithReplace(),
)
if err != nil {
t.Error("sandbox creation failed:", err)
}
})
}
msb --version: msb 0.4.5
Go SDK: v0.0.0-20260514032308-b92ec752f916
While trying to pass a long environment variable to a VM I found that it will crash immediately on startup if the env var is too long. If the value is 128 bytes it works, but around 1500 bytes it crashes.
These tests demonstrate the issue:
msb --version:msb 0.4.5Go SDK:
v0.0.0-20260514032308-b92ec752f916