{"record":{"id":"1fea3484de6b9bd5","repo":"dagger/dagger","slug":"failed-to-encode-spec-w","errorCode":null,"errorMessage":"failed to encode spec: %w","messagePattern":"failed to encode spec: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/engineutil/executor_spec.go","lineNumber":1250,"sourceCode":"func (c *Client) runContainer(ctx context.Context, state *execState) (rerr error) {\n\tbundle := filepath.Join(c.ExecutorRoot, state.id)\n\tif err := os.Mkdir(bundle, 0o711); err != nil {\n\t\treturn err\n\t}\n\tstate.cleanups.Add(\"remove bundle\", func() error {\n\t\treturn os.RemoveAll(bundle)\n\t})\n\n\tconfigPath := filepath.Join(bundle, \"config.json\")\n\tf, err := os.Create(configPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tif err := json.NewEncoder(f).Encode(state.spec); err != nil {\n\t\treturn fmt.Errorf(\"failed to encode spec: %w\", err)\n\t}\n\tf.Close()\n\n\tlg := bklog.G(ctx).\n\t\tWithField(\"id\", state.id).\n\t\tWithField(\"args\", state.spec.Process.Args)\n\tif state.execMD != nil {\n\t\tif state.execMD.CallDigest != \"\" {\n\t\t\tlg = lg.WithField(\"call_id\", state.execMD.CallDigest)\n\t\t}\n\t}\n\tif state.callerClientID != \"\" {\n\t\tlg = lg.WithField(\"caller_client_id\", state.callerClientID)\n\t}\n\tif state.nestedClientMetadata != nil && state.nestedClientMetadata.ClientID != \"\" {\n\t\tlg = lg.WithField(\"nested_client_id\", state.nestedClientMetadata.ClientID)\n\t}\n\tlg.Info(\"starting container\")\n\tdefer func() {","sourceCodeStart":1232,"sourceCodeEnd":1268,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/engineutil/executor_spec.go#L1232-L1268","documentation":"The engine failed to write the container's OCI runtime spec as the runc bundle config.json (json.NewEncoder(f).Encode(state.spec)). runc cannot start a container without a valid bundle config, so this aborts the container run.","triggerScenarios":"Encoding specs.Spec to the already-created config.json file errors. Since a plain *os.File encode only fails on write errors, this is typically ENOSPC/disk-full, I/O error, or a spec value that fails to marshal (rare).","commonSituations":"Engine host disk full (bundle dir on a full filesystem); storage backend errors; I/O failures on the engine's executor root mount.","solutions":["Check engine host disk space (df) — ENOSPC on the executor root is the most common cause","Check the wrapped inner error to distinguish write failure from marshal failure","Free space or move the engine's data root; restart the engine to clear stale bundles","If it's a marshal error, check for non-serializable spec fields (custom builds)"],"exampleFix":"// diagnosis\n// before (engine host)\ndf -h /var/lib/dagger\n// after: free space or remount storage, then rerun the pipeline","handlingStrategy":"validation","validationCode":"// Precheck on the engine host before starting work:\n// stat -f -c '%a %T' <executor-root>  (free blocks/inodes)\n// alert if free space below threshold, e.g.:\nif free, err := diskFree(executorRoot); err == nil && free < 1<<30 {\n    return fmt.Errorf(\"insufficient disk (%d bytes free) for runc bundle\", free)\n}","typeGuard":null,"tryCatchPattern":"// Go\nif err := json.NewEncoder(f).Encode(state.spec); err != nil {\n    var jerr *json.UnsupportedTypeError\n    if !errors.As(err, &jerr) { // then it was a write error\n        bklog.G(ctx).Errorf(\"config.json write failed (disk full?): %v\", err)\n    }\n    return fmt.Errorf(\"failed to encode spec: %w\", err)\n}","preventionTips":["Monitor disk space and inodes on the engine data root","Set up log rotation / prune old engine state","Alert on ENOSPC in engine logs","Restart the engine after disk-full incidents to clear stale bundles"],"tags":["go","json","runc-bundle","disk"],"backgroundTag":"disk-full","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"}