{"record":{"id":"7091cd8565b7bdd5","repo":"vxcontrol/pentagi","slug":"no-config-found-for-container-s","errorCode":null,"errorMessage":"no config found for container %s","messagePattern":"no config found for container (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/docker/client.go","lineNumber":222,"sourceCode":"\t\tnetwork:        netName,\n\t\tpublicIP:       publicIP,\n\t\tportsBase:      cfg.DockerPortsBase,\n\t\tlabels:         cfg.TenantLabels(),\n\t\tinsideEnv:      cfg.WorkerDockerEnv(),\n\t\tinsideCertPath: cfg.WorkerDockerCertPath(),\n\t}, nil\n}\n\nfunc (dc *dockerClient) RunContainer(\n\tctx context.Context,\n\tcontainerName string,\n\tcontainerType database.ContainerType,\n\tflowID int64,\n\tconfig *container.Config,\n\thostConfig *container.HostConfig,\n) (database.Container, error) {\n\tif config == nil {\n\t\treturn database.Container{}, fmt.Errorf(\"no config found for container %s\", containerName)\n\t}\n\n\tworkDir := filepath.Join(dc.dataDir, fmt.Sprintf(containerLocalCwdTemplate, flowID))\n\tif err := os.MkdirAll(workDir, 0755); err != nil {\n\t\treturn database.Container{}, fmt.Errorf(\"failed to create tmp directory: %w\", err)\n\t}\n\n\thostDir := dc.hostDir\n\tif hostDir != \"\" {\n\t\thostDir = filepath.Join(hostDir, fmt.Sprintf(containerLocalCwdTemplate, flowID))\n\t}\n\n\tlogger := dc.logger.WithContext(ctx).WithFields(logrus.Fields{\n\t\t\"image\":    config.Image,\n\t\t\"name\":     containerName,\n\t\t\"type\":     containerType,\n\t\t\"flow_id\":  flowID,\n\t\t\"work_dir\": workDir,","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/docker/client.go#L204-L240","documentation":"RunContainer requires a non-nil *container.Config describing the image/env/command for the sandbox; without it there is nothing to send to the daemon. When config is nil the function returns the plain error \"no config found for container <name>\". Unlike the other errors in this file, it carries no wrapped cause — it is a caller programming error, not an I/O failure.","triggerScenarios":"RunContainer(ctx, containerName, containerType, flowID, nil, hostConfig) is called with a nil config — e.g. a code path that builds hostConfig (port bindings, capabilities) but fails to build config.Image/Env, or a variable holding the config that was never initialized on some branch.","commonSituations":"Adding a new tool/agent code path that passes an uninitialized *container.Config; a refactor moving config construction behind a helper that returns nil on error paths that were ignored; tests calling RunContainer with only a hostConfig.","solutions":["Fix the caller to always construct and pass &container.Config{Image: ...} before calling RunContainer.","If config is conditionally built, check the builder's error return and propagate it instead of passing nil.","Default to the client's default image when no specific config is needed: &container.Config{Image: dc.GetDefaultImage()}.","Add a unit test covering the call site so nil configs fail fast in CI."],"exampleFix":"// before\nvar cfg *container.Config // built later, nil on early return\ndbContainer, err := dc.RunContainer(ctx, name, ctype, flowID, cfg, hostCfg)\n// after\ncfg, err := buildContainerConfig(tool, flowID)\nif err != nil { return nil, err }\ndbContainer, err := dc.RunContainer(ctx, name, ctype, flowID, cfg, hostCfg)","handlingStrategy":"type-guard","validationCode":"if cfg == nil {\n    cfg = &container.Config{Image: defaultImage} // or return a clear error at the call site\n}","typeGuard":"func validContainerConfig(cfg *container.Config) bool {\n    return cfg != nil && cfg.Image != \"\"\n}\n// usage: if !validContainerConfig(cfg) { return fmt.Errorf(\"container config/image required\") }","tryCatchPattern":null,"preventionTips":["Never declare *container.Config without initializing it; construct inline at the call site.","Have builders of configs return (config, error) and check err before calling RunContainer.","Add a linter/test that exercises every RunContainer call path with a non-nil config.","Use a small wrapper function that validates config before delegating to RunContainer."],"tags":["programming-error","nil-argument","docker"],"backgroundTag":"nil-config-argument","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}