dagger/dagger · error
delete module %q: %w
Error message
delete module %q: %w
What it means
deleteRemovedConfigRoots deletes a module entry (modules.<name>) from the TOML document when the module exists in the existing config but not in the desired one. Failure of doc.Delete is wrapped as "delete module %q". It means an in-place removal of a module section from dagger.json failed.
Source
Thrown at core/workspace/config_document.go:323
}
nested, ok := value.(map[string]any)
if ok {
flattenConfigValuesInto(flat, fullKey, nested)
continue
}
flat[fullKey] = value
}
}
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)View on GitHub (pinned to 82ba2681db)
Solutions
- Manually remove the [modules.<name>] (and its sub-tables like as-sdk) sections from dagger.json, then retry.
- Rename the module to a bare-safe name (letters, digits-with-leading-letter, hyphens, underscores) before removal.
- Restore a known-good dagger.json from git and re-apply the change with the dagger CLI rather than manual edits.
Example fix
// before: module named with unsafe segment [modules."my.mod"] x = 1 // after: rename module to a safe name [modules.mymod] x = 1
Defensive patterns
Strategy: validation
Validate before calling
if !isBareConfigPathSegment(moduleName) || isAllDigitConfigPathSegment(moduleName) {
return fmt.Errorf("module name %q cannot be updated in place; rename it first", moduleName)
} Try / catch
if err := UpdateConfigBytes(...); err != nil {
if strings.Contains(err.Error(), "delete module") {
// strip the [modules.<name>] block manually from dagger.json, then retry
}
} Prevention
- Name modules with letters, digits, hyphens, and underscores only (not starting with a digit).
- Remove modules via dagger CLI commands instead of editing dagger.json directly.
- Back up dagger.json before module removal operations.
When it happens
Trigger: UpdateConfigBytes called with a desired Config lacking a module name that exists in the existing Config, and doc.Delete("modules.<name>") errors — usually due to a module name that formats into an unresolvable dotted path (unsafe characters or all digits).
Common situations: Removing a module whose name contains dots, quotes, spaces, or is purely numeric (e.g. a module literally named "123"), or hand-crafted dagger.json where [modules] tables were edited into shapes the path parser cannot match.
Related errors
- update workspace config: %w
- install SDK modules at %s: %w
- install SDK for discovered module %q: %w
- workspace env %q requires dagger.toml
- module %q is not installed in the workspace
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/e9e153b41d594147.
Report an issue: GitHub.