juicedata/juicefs · error
set worker environment %q: %s
Error message
set worker environment %q: %s
What it means
loadClusterWorkerConfig reads the worker configuration from the cluster master over stdin via sync.ReadClusterWorkerConfig and then applies the returned environment variables with os.Setenv. This error is wrapped around a failure of os.Setenv for one of those worker-provided keys, typically because the key or value is malformed for the OS (e.g. contains '=' or a NUL byte, or the environment cannot be extended). It surfaces as part of a chained error whose inner text is the original os.Setenv failure.
Source
Thrown at cmd/sync.go:523
return nil, fmt.Errorf("load %s key: %w", mode, err)
}
encryptor, err := object.NewDataEncryptor(object.NewKeyEncryptor(privKey), algo)
if err != nil {
return nil, fmt.Errorf("create %sor: %w", mode, err)
}
return object.NewChunkedEncrypted(store, encryptor), nil
}
func loadClusterWorkerConfig(r io.Reader) (string, string, error) {
src, dst, env, err := sync.ReadClusterWorkerConfig(r)
if err != nil {
return "", "", err
}
for key, value := range env {
if err := os.Setenv(key, value); err != nil {
return "", "", fmt.Errorf("set worker environment %q: %s", key, err)
}
}
return src, dst, nil
}
func doSync(c *cli.Context) error {
isWorker := c.String("manager") != ""
var workerSrcURL, workerDstURL string
if isWorker {
var err error
// need init before NewConfigFromCli, otherwise the env will not be applied(umask)
workerSrcURL, workerDstURL, err = loadClusterWorkerConfig(os.Stdin)
if err != nil {
return fmt.Errorf("load worker config: %s", err)
}
}
setup(c, 2)
if c.IsSet("include") && !c.IsSet("exclude") {View on GitHub (pinned to c9a67b23e8)
Solutions
- Inspect the inner error text after 'set worker environment' to identify which key failed and why.
- Check what the master writes via sync.WriteClusterWorkerConfig — ensure keys are valid env names (no '=', NUL, or empty).
- Re-run the sync and capture the master's worker config stream to verify the env payload.
- If the master is a custom script, sanitize the env map before sending.
Example fix
// before: master sends raw user input as env key
env[userInput] = value
// after: validate/sanitize the key before sending
if !isValidEnvKey(userInput) {
return fmt.Errorf("invalid env key %q", userInput)
}
env[userInput] = value Defensive patterns
Strategy: validation
Validate before calling
for key, value := range env {
if key == "" || strings.ContainsAny(key, "=\x00") {
return fmt.Errorf("invalid worker env key %q", key)
}
} Prevention
- Validate env keys conform to the platform's env-name rules before sending them to workers
- Keep master and worker JuiceFS versions in sync so the IPC config format matches
When it happens
Trigger: Running `juicefs sync --worker` (isWorker mode) where the master sends env pairs and one pair fails os.Setenv — most commonly an env key containing '=' or NUL, or an empty key.
Common situations: A custom or buggy cluster master feeding malformed environment variables to workers; corrupted IPC stream between master and worker; platform restrictions on env var names in restricted containers.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- load worker config: %s
- Cannot load default config
- Unsupported ByteMultiple " + sMultiple
- wrong type
- random, backward, skip are only valid under read
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/fe9f6e0580b0d0a8.
Report an issue: GitHub.