{"record":{"id":"b6aa31703ee14b97","repo":"plandex-ai/plandex","slug":"failed-to-set-pending-results-applied-s","errorCode":null,"errorMessage":"failed to set pending results applied: %s","messagePattern":"failed to set pending results applied: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/apply.go","lineNumber":588,"sourceCode":"\t\tfmt.Println()\n\t\tfmt.Println(\"✅ Commands succeeded\")\n\t\tonSuccess()\n\t}\n}\n\nfunc apiApplyPlan(planId, branch string) (string, error) {\n\tauthVars := MustVerifyAuthVarsSilent(auth.Current.IntegratedModelsMode)\n\n\tvar commitSummary string\n\n\tlog.Println(\"Applying plan with API call\")\n\n\tcommitSummary, apiErr := api.Client.ApplyPlan(planId, branch, shared.ApplyPlanRequest{\n\t\tAuthVars: authVars,\n\t})\n\n\tif apiErr != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to set pending results applied: %s\", apiErr.Msg)\n\t}\n\n\treturn commitSummary, nil\n}\n\nfunc commitApplied(autoCommit bool, commitSummary string, updatedFiles []string, currentPlanState *shared.CurrentPlanState) (err error) {\n\tconfirmed := autoCommit\n\tif !autoCommit {\n\t\tfmt.Println(\"✏️  Plandex can commit these updates with an automatically generated message.\")\n\t\tfmt.Println()\n\t\t// fmt.Println(\"ℹ️  Only the files that Plandex is updating will be included the commit. Any other changes, staged or unstaged, will remain exactly as they are.\")\n\t\t// fmt.Println()\n\t\tconfirmed, err = term.ConfirmYesNo(\"Commit Plandex updates now?\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get confirmation user input: %s\", err)\n\t\t}\n\t}\n","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/apply.go#L570-L606","documentation":"apiApplyPlan calls the Plandex server's ApplyPlan API to mark a plan's pending results as applied and get back a commit summary. When the server responds with an error, the CLI wraps apiErr.Msg in this error. It means the server rejected or failed the apply-plan request, not a local git/file problem.","triggerScenarios":"api.Client.ApplyPlan(planId, branch, shared.ApplyPlanRequest{AuthVars: ...}) returns a non-nil apiErr — server-side failure applying the plan, expired/invalid session auth, plan or branch not found, or missing integrated-model auth vars.","commonSituations":"Server restarted or plan context lost; branch renamed or deleted server-side; auth token expired mid-session; integrated models mode enabled without valid API keys configured.","solutions":["Re-run 'plandex apply' after confirming the plan and branch still exist (plandex current, plandex branches)","Log in again (plandex login) to refresh an expired session token","Verify integrated-model auth vars are set if IntegratedModelsMode is on (MustVerifyAuthVarsSilent runs first)","Check the Plandex server logs for the underlying error reported in apiErr.Msg"],"exampleFix":"// before\nif apiErr != nil {\n  return \"\", fmt.Errorf(\"failed to set pending results applied: %s\", apiErr.Msg)\n}\n// after\nif apiErr != nil {\n  if apiErr.Status == http.StatusUnauthorized {\n    return \"\", fmt.Errorf(\"session expired, run 'plandex login': %s\", apiErr.Msg)\n  }\n  return \"\", fmt.Errorf(\"failed to set pending results applied: %s\", apiErr.Msg)\n}","handlingStrategy":"try-catch","validationCode":"// before applying\nif out, err := exec.Command(\"plandex\", \"current\").Output(); err != nil {\n  log.Fatal(\"no active plan context: \", err)\n}\nif authVarsMissing() { log.Fatal(\"set integrated model auth vars before applying\") }","typeGuard":"func isApiErr(err error) (msg string, ok bool) {\n  type apiErr interface{ ErrorMsg() string }\n  if e, ok := err.(apiErr); ok { return e.ErrorMsg(), true }\n  return \"\", false\n}","tryCatchPattern":"commitSummary, err := apiApplyPlan(planId, branch)\nif err != nil {\n  if strings.Contains(err.Error(), \"unauthorized\") || strings.Contains(err.Error(), \"auth\") {\n    // prompt re-login then retry once\n  }\n  return fmt.Errorf(\"apply failed: %w\", err)\n}","preventionTips":["Re-authenticate before long sessions; tokens expire","Verify plan/branch exist with plandex CLI before applying","Keep integrated-model API keys configured and valid","Monitor server availability before scripted applies"],"tags":["go","api","cli"],"backgroundTag":"api-request-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}