{"record":{"id":"1dcfda2e20fe2b65","repo":"dagger/dagger","slug":"failed-to-evaluate-container-w","errorCode":null,"errorMessage":"failed to evaluate container: %w","messagePattern":"failed to evaluate container: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/terminal.go","lineNumber":190,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get client metadata: %w\", err)\n\t}\n\tif clientMetadata.SessionID == \"\" {\n\t\treturn fmt.Errorf(\"terminal attach container: empty session ID\")\n\t}\n\tattachedAny, err := cache.AttachResult(ctx, clientMetadata.SessionID, srv, containerRes)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to attach terminal container: %w\", err)\n\t}\n\tattached, ok := attachedAny.(dagql.ObjectResult[*Container])\n\tif !ok {\n\t\treturn fmt.Errorf(\"failed to attach terminal container: expected %T, got %T\", containerRes, attachedAny)\n\t}\n\tcontainerRes = attached\n\t// HACK: ensure that container is entirely built before interrupting nice\n\t// progress output with the terminal\n\tif err := cache.Evaluate(ctx, containerRes); err != nil {\n\t\treturn fmt.Errorf(\"failed to evaluate container: %w\", err)\n\t}\n\tquery, err := CurrentQuery(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tcontainer, err = cloneContainerForTerminal(ctx, query, containerRes.Self())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to clone terminal container: %w\", err)\n\t}\n\n\tterm, output, err := prepTerminal(ctx, selectedID, execErr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer term.Close(bkgwpb.UnknownExitStatus) // always close term; it's wrapped in a once so it won't be called multiple times\n\tcontainer.Config.Env = prepTerminalEnv(output, container.Config.Env)\n\n\tcontainerRes, err = newSyntheticTerminalContainerResult(srv, container, \"terminal_container\")","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/terminal.go#L172-L208","documentation":"The container's full evaluation (build steps) failed before the terminal could be opened. Dagger intentionally evaluates the container completely first so that progress output isn't interrupted by the terminal UI, then wraps any evaluation error.","triggerScenarios":"Calling Container.Terminal() on a container whose lazily-evaluated DAG (FROM, RUN, etc.) fails during evaluation, e.g. a failing RUN step or unresolvable image.","commonSituations":"Bad base image tag or private registry auth; failing RUN command; network failure during build; a multi-stage build step error surfacing only when terminal forces evaluation.","solutions":["Read the wrapped inner error — it names the failing build step","Run the same chain without .Terminal() to see the underlying build error directly","Fix the failing step (correct image ref, add registry auth, fix RUN command)","Use dagger call with --progress to see full build output"],"exampleFix":"// before\nctr := client.Container().From(\"alpine:nope\").Terminal()\n// after\nctr := client.Container().From(\"alpine:latest\").Terminal()","handlingStrategy":"validation","validationCode":"// pre-evaluate without terminal to surface build errors cleanly\nif _, err := ctr.Sync(ctx); err != nil {\n    return fmt.Errorf(\"container not buildable, fix before terminal: %w\", err)\n}\n_, err := ctr.Terminal(ctx)","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var execErr *dagger.ExecError\n    if errors.As(err, &execErr) { /* inspect execErr.ExitCode */ }\n    return err\n}","preventionTips":["Run dagger call with --progress to catch failing steps early","Pin base image tags you control","Verify registry auth (DOCKER_CONFIG / ~/.docker/config.json) before terminal","Test the build chain without .Terminal() first"],"tags":["terminal","container-build","evaluation"],"backgroundTag":"container-evaluation-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"}