{"record":{"id":"85b016c0533a15ad","repo":"plandex-ai/plandex","slug":"no-org-id","errorCode":null,"errorMessage":"no org id","messagePattern":"no org id","errorType":"http","errorClass":null,"httpStatus":401,"severity":"error","filePath":"app/server/handlers/auth_helpers.go","lineNumber":518,"sourceCode":"\tif err != nil {\n\t\tlog.Printf(\"error getting user: %v\\n\", err)\n\t\tif raiseErr {\n\t\t\thttp.Error(w, \"error getting user\", http.StatusInternalServerError)\n\t\t}\n\t\treturn nil\n\t}\n\n\tif !requireOrg {\n\t\treturn &types.ServerAuth{\n\t\t\tAuthToken: authToken,\n\t\t\tUser:      user,\n\t\t}\n\t}\n\n\tif parsed.OrgId == \"\" {\n\t\tlog.Println(\"no org id\")\n\t\tif raiseErr {\n\t\t\thttp.Error(w, \"no org id\", http.StatusUnauthorized)\n\t\t}\n\t\treturn nil\n\t}\n\n\t// validate the org membership\n\tisMember, err := db.ValidateOrgMembership(authToken.UserId, parsed.OrgId)\n\n\tif err != nil {\n\t\tlog.Printf(\"error validating org membership: %v\\n\", err)\n\t\tif raiseErr {\n\t\t\thttp.Error(w, \"error validating org membership\", http.StatusInternalServerError)\n\t\t}\n\t\treturn nil\n\t}\n\n\tif !isMember {\n\t\t// check if there's an invite for this user and accept it if so (adds the user to the org)\n\t\tinvite, err := db.GetActiveInviteByEmail(parsed.OrgId, user.Email)","sourceCodeStart":500,"sourceCodeEnd":536,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/auth_helpers.go#L500-L536","documentation":"The user authenticated but the request carried no org id (parsed.OrgId == \"\"), so execAuthenticate logs 'no org id' and returns HTTP 401 when raiseErr is true. Endpoints that call Authenticate with requireOrg=true need an org-scoped request.","triggerScenarios":"Requests parsed by GetAuthHeader that require an org context but whose token/header omitted OrgId, hitting org-scoped handlers.","commonSituations":"Clients that authenticate per-user but forget to select/pass an org; tokens minted before org support; API calls made outside an org workspace context.","solutions":["Have the client include OrgId in the auth header/payload for org-scoped requests","Select an active org in the client before making the call","Mint a new token that includes the org claim","Use a non-org (requireOrg=false) auth path for user-only endpoints"],"exampleFix":"// before\nreq.Header.Set(\"Authorization\", \"Bearer \"+token) // no org\n// after\nreq.Header.Set(\"Authorization\", \"Bearer \"+token)\nreq.Header.Set(\"X-Org-Id\", orgID)","handlingStrategy":"validation","validationCode":"if orgID == \"\" {\n\treturn fmt.Errorf(\"org id required: select an org before calling org-scoped endpoints\")\n}","typeGuard":null,"tryCatchPattern":"if err := doCall(ctx); err != nil {\n\tvar apiErr *APIError\n\tif errors.As(err, &apiErr) && apiErr.StatusCode == 401 && strings.Contains(apiErr.Message, \"no org id\") {\n\t\treturn promptOrgSelection() // attach OrgId and retry\n\t}\n\treturn err\n}","preventionTips":["Always include OrgId in auth payload/header for org-scoped calls","Select a default org at client startup after login","Refresh the org selection when switching workspaces","Mint tokens that carry the org claim where supported"],"tags":["auth","org","unauthorized"],"backgroundTag":"missing-org-context","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}