{"record":{"id":"c8f410bbb7d8bae3","repo":"hashicorp/terraform","slug":"errinvalidremoteplanformat","errorCode":"ErrInvalidRemotePlanFormat","errorMessage":"invalid remote plan format, must be 1","messagePattern":"invalid remote plan format, must be 1","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/cloudplan/saved_plan.go","lineNumber":13,"sourceCode":"// Copyright IBM Corp. 2014, 2026\n// SPDX-License-Identifier: BUSL-1.1\npackage cloudplan\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar ErrInvalidRemotePlanFormat = errors.New(\"invalid remote plan format, must be 1\")\nvar ErrInvalidRunID = errors.New(\"invalid run ID\")\nvar ErrInvalidHostname = errors.New(\"invalid hostname\")\n\ntype SavedPlanBookmark struct {\n\tRemotePlanFormat int    `json:\"remote_plan_format\"`\n\tRunID            string `json:\"run_id\"`\n\tHostname         string `json:\"hostname\"`\n}\n\nfunc NewSavedPlanBookmark(runID, hostname string) SavedPlanBookmark {\n\treturn SavedPlanBookmark{\n\t\tRemotePlanFormat: 1,\n\t\tRunID:            runID,\n\t\tHostname:         hostname,\n\t}\n}\n\nfunc LoadSavedPlanBookmark(filepath string) (SavedPlanBookmark, error) {","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/cloudplan/saved_plan.go#L1-L31","documentation":"Exported sentinel ErrInvalidRemotePlanFormat (cloudplan/saved_plan.go:13, code=ErrInvalidRemotePlanFormat). When reading a saved-plan bookmark file, StateRead/Read unmarshals JSON and checks bookmark.RemotePlanFormat == 1; any other value (0 from an empty/garbage file, or a future incompatible format) returns this error. As the comments at saved_plan.go:50-54 note, these errors imply the file probably is not a saved plan bookmark at all.","triggerScenarios":"terraform show/apply pointing at a plan file (e.g. `terraform show foo.tfplan`) where foo.tfplan is not a cloud saved-plan bookmark — e.g. a local plan, a corrupt file, or unrelated bytes — so RemotePlanFormat != 1 after json.Unmarshal.","commonSituations":"Mixing up a local-backend plan file with a cloud-backend bookmark. Passing a stale plan from a different Terraform version. A truncated/empty file producing a zero-value struct.","solutions":["Re-generate the plan file with `terraform plan -out=<file>` using the same backend, then pass it to terraform show/apply.","Confirm you are using the cloud/remote backend for both the plan and the show/apply step.","If the file is hand-edited or from another tool, treat it as not-a-plan and regenerate it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Peek at the bookmark before handing it to StateRead.\nfunc isValidRemoteBookmark(b cloudplan.SavedPlanBookmark) error {\n    if b.RemotePlanFormat != 1 { return cloudplan.ErrInvalidRemotePlanFormat }\n    if b.Hostname == \"\" { return cloudplan.ErrInvalidHostname }\n    if b.RunID == \"\" || !strings.HasPrefix(b.RunID, \"run-\") { return cloudplan.ErrInvalidRunID }\n    return nil\n}","typeGuard":"func isRemotePlanBookmark(data []byte) bool {\n    var b cloudplan.SavedPlanBookmark\n    if err := json.Unmarshal(data, &b); err != nil { return false }\n    return b.RemotePlanFormat == 1\n}","tryCatchPattern":"b, err := cloudplan.StateRead(path)\nif err != nil {\n    if errors.Is(err, cloudplan.ErrInvalidRemotePlanFormat) {\n        // not a cloud plan file; try local plan path or re-plan\n    }\n}","preventionTips":["Generate plan files with the same backend you'll show/apply with.","Don't reuse plan files across Terraform versions.","Use errors.Is against the exported sentinels."],"tags":["terraform","cloud-backend","cloudplan","saved-plan","json","validation"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}