{"record":{"id":"eb6177dd983b6425","repo":"dagger/dagger","slug":"delete-env-q-w","errorCode":null,"errorMessage":"delete env %q: %w","messagePattern":"delete env %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/workspace/config_document.go","lineNumber":332,"sourceCode":"\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)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc ensureEmptyEnvSections(doc *neontoml.Document, envs map[string]EnvOverlay) error {\n\tfor envName, env := range envs {\n\t\tif len(env.Modules) > 0 {","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/workspace/config_document.go#L314-L350","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before: all-digit env name breaks dotted-path delete\n[env.2024]\nx = true\n\n// after: safe env name\n[env.prod2024]\nx = true","handlingStrategy":"validation","validationCode":"if isAllDigitConfigPathSegment(envName) || !isBareConfigPathSegment(envName) {\n    return fmt.Errorf(\"env %q is unsafe for in-place config update\", envName)\n}","typeGuard":null,"tryCatchPattern":"if err := UpdateConfigBytes(...); err != nil {\n    if strings.Contains(err.Error(), \"delete env\") {\n        // remove the [env.<name>] table manually and re-run the update\n    }\n}","preventionTips":["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."],"tags":["toml","config","env"],"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"}