{"record":{"id":"f26417da7b905c00","repo":"docker/compose","slug":"could-not-find-s-w","errorCode":null,"errorMessage":"could not find %s: %w","messagePattern":"could not find (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/dependencies.go","lineNumber":317,"sourceCode":"// AddVertex adds a vertex to the Graph\nfunc (g *Graph) AddVertex(key string, service string, initialStatus ServiceStatus) {\n\tg.lock.Lock()\n\tdefer g.lock.Unlock()\n\n\tv := NewVertex(key, service, initialStatus)\n\tg.Vertices[key] = v\n}\n\n// AddEdge adds a relationship of dependency between vertices `source` and `destination`\nfunc (g *Graph) AddEdge(source string, destination string) error {\n\tg.lock.Lock()\n\tdefer g.lock.Unlock()\n\n\tsourceVertex := g.Vertices[source]\n\tdestinationVertex := g.Vertices[destination]\n\n\tif sourceVertex == nil {\n\t\treturn fmt.Errorf(\"could not find %s: %w\", source, api.ErrNotFound)\n\t}\n\tif destinationVertex == nil {\n\t\treturn fmt.Errorf(\"could not find %s: %w\", destination, api.ErrNotFound)\n\t}\n\n\t// If they are already connected\n\tif _, ok := sourceVertex.Children[destination]; ok {\n\t\treturn nil\n\t}\n\n\tsourceVertex.Children[destination] = destinationVertex\n\tdestinationVertex.Parents[source] = sourceVertex\n\n\treturn nil\n}\n\n// Leaves returns the slice of leaves of the graph\nfunc (g *Graph) Leaves() []*Vertex {","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/dependencies.go#L299-L335","documentation":"Graph.AddEdge was called with a source vertex that was never added to the in-memory dependency graph. In practice this is the raw not-found error that resurfaces when a required depends_on target is neither an active service nor a disabled-by-profile service — i.e. it simply does not exist in the project.","triggerScenarios":"depends_on references a service name not defined in the (loaded) project — typo, wrong override file combination, or a service removed while depends_on remains — and it is required (default) and not profile-disabled.","commonSituations":"Typos in service names; compose -f overlay files that drop the depended-on service; renamed service without updating dependents; environment-variable-conditional services (profiles removed via scale).","solutions":["Fix the depends_on name to match a defined service","Check which files were merged: docker compose config to see final services","Remove the stale depends_on entry","If it should exist behind a profile, add profiles to it (then error 191's guidance applies)"],"exampleFix":"# before\nservices:\n  api:\n    depends_on: [databse]  # typo\n# after\nservices:\n  api:\n    depends_on: [database]","handlingStrategy":"validation","validationCode":"// verify every depends_on source exists in the merged project\nfor _, svc := range project.Services {\n    if _, ok := project.Services[svc.Name]; !ok {\n        return fmt.Errorf(\"service %s missing from project\", svc.Name)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"could not find\") && strings.HasSuffix(err.Error(), api.ErrNotFound.Error()) {\n    // run docker compose config, fix names, re-parse and retry\n}","preventionTips":["Run docker compose config as a pre-deploy lint step","Rename services with grep across all compose files","Keep depends_on lists short and reviewed in PRs"],"tags":["dependencies","compose-file","not-found"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}