dagger/dagger · error
delete env %q: %w
Error message
delete env %q: %w
What it means
deleteRemovedConfigRoots deletes an environment entry (env.<name>) when it exists in the existing config but not in the desired one. doc.Delete failure is wrapped as "delete env %q". It indicates the env section could not be removed from the in-memory TOML document during a config update.
Source
Thrown at core/workspace/config_document.go:332
}
}
func deleteRemovedConfigRoots(doc *neontoml.Document, existingCfg, desiredCfg *Config) error {
for name := range existingCfg.Modules {
if _, ok := desiredCfg.Modules[name]; ok {
continue
}
if err := doc.Delete("modules." + formatConfigPathSegment(name)); err != nil {
return fmt.Errorf("delete module %q: %w", name, err)
}
}
for envName := range existingCfg.Env {
if _, ok := desiredCfg.Env[envName]; ok {
continue
}
if err := doc.Delete("env." + formatConfigPathSegment(envName)); err != nil {
return fmt.Errorf("delete env %q: %w", envName, err)
}
}
for host := range existingCfg.Ports {
if _, ok := desiredCfg.Ports[host]; ok {
continue
}
if err := doc.Delete("ports." + formatConfigPathSegment(host)); err != nil {
return fmt.Errorf("delete port %q: %w", host, err)
}
}
return nil
}
func ensureEmptyEnvSections(doc *neontoml.Document, envs map[string]EnvOverlay) error {
for envName, env := range envs {
if len(env.Modules) > 0 {View on GitHub (pinned to 82ba2681db)
Solutions
- Remove the [env.<name>] section manually from dagger.json and retry the update.
- Rename the environment to a safe bare segment before deletion.
- Restore dagger.json from version control and let the dagger CLI re-apply changes.
Example fix
// before: all-digit env name breaks dotted-path delete [env.2024] x = true // after: safe env name [env.prod2024] x = true
Defensive patterns
Strategy: validation
Validate before calling
if isAllDigitConfigPathSegment(envName) || !isBareConfigPathSegment(envName) {
return fmt.Errorf("env %q is unsafe for in-place config update", envName)
} Try / catch
if err := UpdateConfigBytes(...); err != nil {
if strings.Contains(err.Error(), "delete env") {
// remove the [env.<name>] table manually and re-run the update
}
} Prevention
- Use descriptive non-numeric environment names (prod, staging) instead of numeric ones.
- Delete environments through the dagger CLI, not by editing dagger.json.
- Verify dagger.json parses cleanly before batch config operations.
When it happens
Trigger: UpdateConfigBytes where an env name present in existingCfg.Env is missing from desiredCfg.Env and doc.Delete("env.<name>") fails, e.g. when the env name is an all-digit or non-bare segment that the dotted-path parser misreads (all digits parse as a float).
Common situations: Deleting an environment whose name is numeric (e.g. env "2024"), or dagger.json where the [env] table was hand-edited so the entry no longer matches the map key.
Related errors
- drop empty env header: %w
- create env %q section: %w
- finalize env %q section: %w
- update workspace config: %w
- install SDK modules at %s: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/eb6177dd983b6425.
Report an issue: GitHub.