{"record":{"id":"80a119d097b1f88a","repo":"hashicorp/terraform","slug":"errinvalidrunid","errorCode":"ErrInvalidRunID","errorMessage":"invalid run ID","messagePattern":"invalid run ID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/cloudplan/saved_plan.go","lineNumber":14,"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) {\n\tbookmark := SavedPlanBookmark{}","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/cloudplan/saved_plan.go#L1-L32","documentation":"Exported sentinel ErrInvalidRunID (cloudplan/saved_plan.go:14, code=ErrInvalidRunID). After unmarshalling a bookmark, Read checks the RunID: it must be non-empty AND start with \"run-\" (saved_plan.go:59). An empty run ID or one without the 'run-' prefix returns this error, indicating the file is not a valid cloud saved-plan bookmark.","triggerScenarios":"Reading a JSON bookmark whose `run_id` field is missing, empty, or malformed (e.g. a manually crafted file with `{\"remote_plan_format\":1,\"hostname\":\"x\",\"run_id\":\"abc\"}` — no 'run-' prefix) — saved_plan.go:59 condition fires.","commonSituations":"Editing or templating a plan bookmark and stripping/altering the run_id. A corrupt or partial bookmark file. Using a file that is JSON but not an actual cloud plan bookmark.","solutions":["Regenerate the plan file with terraform plan -out=<file> against the cloud backend so a valid run-<id> is written.","Do not hand-edit the bookmark; if you must migrate runs, reference the run via the UI/API and re-plan."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func validRunID(id string) bool { return id != \"\" && strings.HasPrefix(id, \"run-\") }","typeGuard":"func isLikelyRunID(s string) bool {\n    return strings.HasPrefix(s, \"run-\")\n}","tryCatchPattern":"b, err := cloudplan.StateRead(path)\nif err != nil {\n    if errors.Is(err, cloudplan.ErrInvalidRunID) {\n        // bookmark run_id is missing/malformed; regenerate the plan file\n    }\n}","preventionTips":["Never hand-edit bookmark run_id values.","Regenerate plan files with terraform plan -out rather than templating them.","Branch with errors.Is(err, cloudplan.ErrInvalidRunID)."],"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"}