{"record":{"id":"b864311b4c684ba4","repo":"hashicorp/terraform","slug":"request-was-canceled","errorCode":null,"errorMessage":"request was canceled","messagePattern":"request was canceled","errorType":"exception","errorClass":"ErrRequestCanceled","httpStatus":null,"severity":"warning","filePath":"internal/pluginshared/errors.go","lineNumber":17,"sourceCode":"// Copyright IBM Corp. 2014, 2026\n// SPDX-License-Identifier: BUSL-1.1\n\npackage pluginshared\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n)\n\nvar (\n\t// ErrPluginNotSupported is the error returned when the upstream HCP Terraform does not\n\t// have a manifest.\n\tErrPluginNotSupported = errors.New(\"plugin is not supported by the remote version of Terraform Enterprise\")\n\n\t// ErrRequestCanceled is the error returned when the context was cancelled.\n\tErrRequestCanceled = errors.New(\"request was canceled\")\n\n\t// ErrArchNotSupported is the error returned when the plugin does not have a build for the\n\t// current OS/Architecture.\n\tErrArchNotSupported = errors.New(\"plugin is not supported by your computer architecture/operating system\")\n\n\t// ErrPluginNotFound is the error returned when the plugin manifest points to a location\n\t// that was does not exist.\n\tErrPluginNotFound = errors.New(\"plugin download was not found in the location specified in the manifest\")\n)\n\n// ErrQueryFailed is the error returned when the plugin http client request fails\ntype ErrQueryFailed struct {\n\tinner error\n}\n\n// ErrCloudPluginNotVerified is the error returned when the archive authentication process fails\ntype ErrCloudPluginNotVerified struct {\n\tinner error","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/pluginshared/errors.go#L1-L35","documentation":"ErrRequestCanceled is returned by GetManifest / DownloadFile when the underlying HTTP request failed because the provided context was cancelled (errors.Is(err, context.Canceled)). It distinguishes a user-initiated or parent cancellation from a genuine network/transport failure so callers can stop retrying.","triggerScenarios":"The context passed to BasePluginClient (b.ctx) is cancelled while httpClient.Do(req) is in flight, OR the retryablehttp transport surfaces context.Canceled. Detected at client.go:214-216 (DownloadFile) and the analogous check in GetManifest.","commonSituations":"User pressed Ctrl+C during a plugin download/manifest fetch; a parent operation timed out and cancelled its context; a CI runner was killed; SIGTERM propagation cancelled the request.","solutions":["Treat ErrRequestCanceled as terminal — do not retry; surface 'cancelled by user' to the user.","If cancellations are unexpected, audit the context lifecycle upstream to find premature cancellation (e.g. a request-scoped context being reused).","Increase or remove the deadline on the parent context if the operation legitimately needs more time.","Separate user-cancellation handling from network-error handling using errors.Is(err, pluginshared.ErrRequestCanceled)."],"exampleFix":"// before\nerr := client.DownloadFile(url, &buf)\nif err != nil {\n    log.Fatalf(\"download failed: %v\", err)\n}\n\n// after\nerr := client.DownloadFile(url, &buf)\nif errors.Is(err, pluginshared.ErrRequestCanceled) {\n    log.Println(\"download cancelled\")\n    return ctx.Err()\n}\nif err != nil {\n    log.Fatalf(\"download failed: %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Pass a context with the deadline you actually want\nctx, cancel := context.WithTimeout(parentCtx, 60*time.Second)\ndefer cancel()\nclient := BasePluginClient{ctx: ctx, /* ... */}","typeGuard":"func isRequestCanceled(err error) bool {\n    return errors.Is(err, pluginshared.ErrRequestCanceled) || errors.Is(err, context.Canceled)\n}","tryCatchPattern":"if err := client.DownloadFile(url, &buf); err != nil {\n    if errors.Is(err, pluginshared.ErrRequestCanceled) {\n        return ctx.Err() // stop retrying\n    }\n    return err\n}","preventionTips":["Do not reuse request-scoped contexts across multiple operations.","Distinguish cancellation from real errors so retry loops exit cleanly.","Surface 'cancelled by user' messaging rather than treating cancellation as a failure."],"tags":["cancellation","context","plugin-download","terraform"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}