{"record":{"id":"13c99fe7d3792fc4","repo":"docker/compose","slug":"not-found","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"error_code","errorClass":"ErrNotFound","httpStatus":null,"severity":"error","filePath":"pkg/api/errors.go","lineNumber":31,"sourceCode":"   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n\npackage api\n\nimport (\n\t\"errors\"\n)\n\nconst (\n\t// ExitCodeLoginRequired exit code when command cannot execute because it requires cloud login\n\t// This will be used by VSCode to detect when creating context if the user needs to login first\n\tExitCodeLoginRequired = 5\n)\n\nvar (\n\t// ErrNotFound is returned when an object is not found\n\tErrNotFound = errors.New(\"not found\")\n\t// ErrAlreadyExists is returned when an object already exists\n\tErrAlreadyExists = errors.New(\"already exists\")\n\t// ErrForbidden is returned when an operation is not permitted\n\tErrForbidden = errors.New(\"forbidden\")\n\t// ErrUnknown is returned when the error type is unmapped\n\tErrUnknown = errors.New(\"unknown\")\n\t// ErrNotImplemented is returned when a backend doesn't implement an action\n\tErrNotImplemented = errors.New(\"not implemented\")\n\t// ErrUnsupportedFlag is returned when a backend doesn't support a flag\n\tErrUnsupportedFlag = errors.New(\"unsupported flag\")\n\t// ErrCanceled is returned when the command was canceled by user\n\tErrCanceled = errors.New(\"canceled\")\n\t// ErrParsingFailed is returned when a string cannot be parsed\n\tErrParsingFailed = errors.New(\"parsing failed\")\n\t// ErrNoResources is returned when operation didn't selected any resource\n\tErrNoResources = errors.New(\"no resources\")\n)\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/api/errors.go#L13-L49","documentation":"api.ErrNotFound is the compose api package's sentinel for a missing object (project, service, container). It is a package-level errors.New value designed to be compared with errors.Is / api.IsNotFoundError after unwrapping, so backends (compose, cloud) can map engine-specific not-found conditions onto one canonical error.","triggerScenarios":"Calling api methods that return ErrNotFound directly, or wrapping it with %w when a lookup by name fails; API consumers hit it when the referenced project or service does not exist (e.g. Start on an unknown service name).","commonSituations":"Scripts referencing a service that was renamed or removed from the compose file; race where the project was torn down between commands; programmatic use of pkg/api where a name mismatch occurs.","solutions":["Verify the project/service name exists (docker compose ls, docker compose config --services) and fix the reference.","In Go code, branch on api.IsNotFoundError(err) to handle absence gracefully instead of string matching.","If the project was expected, check you are in the right project directory / -p flag value."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"names=$(docker compose config --services 2>/dev/null)\ncase \" $names \" in *\" $SERVICE \"*) ;; *) echo \"unknown service: $SERVICE\" >&2; exit 1 ;; esac","typeGuard":"func isNotFound(err error) bool { return api.IsNotFoundError(err) }","tryCatchPattern":"if err := backend.Start(ctx, projectName, api.StartOptions{}); err != nil {\n    if api.IsNotFoundError(err) {\n        // object absent: create it or skip\n    }\n    return err\n}","preventionTips":["Always check existence (docker compose ls / config --services) before name-based operations.","Use api.IsNotFoundError instead of string matching on error text."],"tags":["api","sentinel-error","not-found"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}