{"record":{"id":"e9e153b41d594147","repo":"dagger/dagger","slug":"delete-module-q-w","errorCode":null,"errorMessage":"delete module %q: %w","messagePattern":"delete module %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/workspace/config_document.go","lineNumber":323,"sourceCode":"\t\t}\n\n\t\tnested, ok := value.(map[string]any)\n\t\tif ok {\n\t\t\tflattenConfigValuesInto(flat, fullKey, nested)\n\t\t\tcontinue\n\t\t}\n\n\t\tflat[fullKey] = value\n\t}\n}\n\nfunc deleteRemovedConfigRoots(doc *neontoml.Document, existingCfg, desiredCfg *Config) error {\n\tfor name := range existingCfg.Modules {\n\t\tif _, ok := desiredCfg.Modules[name]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tif err := doc.Delete(\"modules.\" + formatConfigPathSegment(name)); err != nil {\n\t\t\treturn fmt.Errorf(\"delete module %q: %w\", name, err)\n\t\t}\n\t}\n\n\tfor envName := range existingCfg.Env {\n\t\tif _, ok := desiredCfg.Env[envName]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tif err := doc.Delete(\"env.\" + formatConfigPathSegment(envName)); err != nil {\n\t\t\treturn fmt.Errorf(\"delete env %q: %w\", envName, err)\n\t\t}\n\t}\n\n\tfor host := range existingCfg.Ports {\n\t\tif _, ok := desiredCfg.Ports[host]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tif err := doc.Delete(\"ports.\" + formatConfigPathSegment(host)); err != nil {\n\t\t\treturn fmt.Errorf(\"delete port %q: %w\", host, err)","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/workspace/config_document.go#L305-L341","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before: module named with unsafe segment\n[modules.\"my.mod\"]\nx = 1\n\n// after: rename module to a safe name\n[modules.mymod]\nx = 1","handlingStrategy":"validation","validationCode":"if !isBareConfigPathSegment(moduleName) || isAllDigitConfigPathSegment(moduleName) {\n    return fmt.Errorf(\"module name %q cannot be updated in place; rename it first\", moduleName)\n}","typeGuard":null,"tryCatchPattern":"if err := UpdateConfigBytes(...); err != nil {\n    if strings.Contains(err.Error(), \"delete module\") {\n        // strip the [modules.<name>] block manually from dagger.json, then retry\n    }\n}","preventionTips":["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."],"tags":["toml","config","modules"],"backgroundTag":"toml-path-delete-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}