{"record":{"id":"2aeaa4b79b8c9f1b","repo":"docker/compose","slug":"no-resources","errorCode":null,"errorMessage":"no resources","messagePattern":"no resources","errorType":"error_code","errorClass":"ErrNoResources","httpStatus":null,"severity":"warning","filePath":"pkg/api/errors.go","lineNumber":47,"sourceCode":"var (\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\n// IsNotFoundError returns true if the unwrapped error is ErrNotFound\nfunc IsNotFoundError(err error) bool {\n\treturn errors.Is(err, ErrNotFound)\n}\n\n// IsAlreadyExistsError returns true if the unwrapped error is ErrAlreadyExists\nfunc IsAlreadyExistsError(err error) bool {\n\treturn errors.Is(err, ErrAlreadyExists)\n}\n\n// IsForbiddenError returns true if the unwrapped error is ErrForbidden\nfunc IsForbiddenError(err error) bool {\n\treturn errors.Is(err, ErrForbidden)\n}\n\n// IsUnknownError returns true if the unwrapped error is ErrUnknown","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/api/errors.go#L29-L65","documentation":"api.ErrNoResources is returned when an operation ends up selecting zero resources to act on. In this repo, pkg/compose/remove.go and pkg/compose/kill.go return it when no container matches the selection, and cmd/compose/remove.go plus cmd/compose/kill.go special-case it with errors.Is to print a friendlier 'no resource ... to remove/kill' style message instead of a hard error.","triggerScenarios":"`docker compose rm` or `docker compose kill` when the selection (service names, --status filters) matches no containers — e.g. project not created yet, already removed, or filtered to nothing.","commonSituations":"Cleanup scripts run repeatedly (idempotent teardown hitting an already-clean project); wrong -p project name; filters like status=running when everything is stopped.","solutions":["Treat it as a no-op in scripts: check `docker compose ls` first, or accept this outcome as success for idempotent cleanup.","Verify the project name/directory and that containers exist (docker compose ps -a) if removal was expected.","In Go code, branch on errors.Is(err, api.ErrNoResources) and continue."],"exampleFix":"# before\ndocker compose rm -f  # may error when nothing matches\n\n# after (idempotent cleanup)\ndocker compose ps -aq | grep -q . && docker compose rm -f || echo 'nothing to remove'","handlingStrategy":"try-catch","validationCode":"# skip teardown when nothing exists\ndocker compose ps -aq | grep -q . || { echo 'no containers; skipping'; exit 0; }","typeGuard":"func isNoResources(err error) bool { return errors.Is(err, api.ErrNoResources) }","tryCatchPattern":"if err := backend.Remove(ctx, project, opts); err != nil {\n    if errors.Is(err, api.ErrNoResources) {\n        return nil // nothing selected: treat as success for idempotent cleanup\n    }\n    return err\n}","preventionTips":["Write cleanup scripts to treat ErrNoResources as a no-op success.","Check docker compose ps -a before acting when you expect resources to exist."],"tags":["api","sentinel-error","no-resources","rm","kill"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}