{"record":{"id":"1f3f0069e4d9b50e","repo":"hashicorp/terraform","slug":"execution-halted-1f3f00","errorCode":null,"errorMessage":"execution halted","messagePattern":"execution halted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/terraform/hook_stop.go","lineNumber":135,"sourceCode":"func (h *stopHook) StartAction(id HookActionIdentity) (HookAction, error) {\n\treturn h.hook()\n}\n\nfunc (h *stopHook) ProgressAction(id HookActionIdentity, progress string) (HookAction, error) {\n\treturn h.hook()\n}\n\nfunc (h *stopHook) CompleteAction(id HookActionIdentity, err error) (HookAction, error) {\n\treturn h.hook()\n}\n\nfunc (h *stopHook) PolicyResult(addr string, resp policy.EvaluationResponse) (HookAction, error) {\n\treturn h.hook()\n}\n\nfunc (h *stopHook) hook() (HookAction, error) {\n\tif h.Stopped() {\n\t\treturn HookActionHalt, errors.New(\"execution halted\")\n\t}\n\n\treturn HookActionContinue, nil\n}\n\n// reset should be called within the lock context\nfunc (h *stopHook) Reset() {\n\tatomic.StoreUint32(&h.stop, 0)\n}\n\nfunc (h *stopHook) Stop() {\n\tatomic.StoreUint32(&h.stop, 1)\n}\n\nfunc (h *stopHook) Stopped() bool {\n\treturn atomic.LoadUint32(&h.stop) == 1\n}\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/terraform/hook_stop.go#L117-L153","documentation":"Returned by the internal stopHook on every hook callback once Stop() has been invoked (atomic flag set). It causes Terraform to return HookActionHalt plus an 'execution halted' error, propagating the user's interrupt through the graph walk so in-flight operations wind down. It is the internal mechanism behind Ctrl+C / SIGINT graceful stop.","triggerScenarios":"stopHook.hook() at hook_stop.go:133-138 checks h.Stopped(); if true it returns (HookActionHalt, errors.New(\"execution halted\")). Triggered after Stop() sets the atomic flag, typically from the signal handler.","commonSituations":"User pressed Ctrl+C (first SIGINT → graceful stop); a parent process sent SIGTERM; an explicit programmatic stop was requested via the Terraform exec interface.","solutions":["Treat it as expected on interrupt — do not retry the operation automatically; let Terraform finish stopping.","If the halt was unintended, investigate what sent the stop signal (orchestrator, wrapper script, OOM killer sending SIGTERM).","Send a second interrupt (SIGINT) to force a harder stop if graceful halt is itself stuck.","Ensure context handling in your wrapper distinguishes user-initiated stop from real failures."],"exampleFix":"n/a — represents an intentional user/system stop, not a recoverable error. Handle by surfacing 'operation cancelled' to the caller.","handlingStrategy":"try-catch","validationCode":"n/a — interruption is external; cannot be pre-validated.","typeGuard":"func isExecutionHalted(err error) bool {\n    return err != nil && err.Error() == \"execution halted\"\n}","tryCatchPattern":"// Hook errors surface through the graph walk; check for halt\nif err != nil && err.Error() == \"execution halted\" {\n    return errors.New(\"operation cancelled by user\")\n}","preventionTips":["Distinguish user-initiated stop from real failures in your wrapper.","Send a second SIGINT to force-stop if graceful halt hangs.","Investigate unexpected stops (orchestrator SIGTERM, OOM killer)."],"tags":["interrupt","stop","graceful-shutdown","terraform"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}