plandex-ai/plandex · error
project does not exist in org
Error message
project does not exist in org
What it means
This 404 is returned by authorizeProjectOptional when db.ProjectExists reports the projectId does not exist in the caller's organization. It means the project either truly does not exist, was deleted/archived, or belongs to a different org than the authenticated user's. shouldErr=true via authorizeProject makes this response mandatory; authorizeProjectOptional with shouldErr=false returns false silently instead.
Source
Thrown at app/server/handlers/auth_helpers.go:634
func authorizeProject(w http.ResponseWriter, projectId string, auth *types.ServerAuth) bool {
return authorizeProjectOptional(w, projectId, auth, true)
}
func authorizeProjectOptional(w http.ResponseWriter, projectId string, auth *types.ServerAuth, shouldErr bool) bool {
log.Println("authorizing project")
projectExists, err := db.ProjectExists(auth.OrgId, projectId)
if err != nil {
log.Printf("error validating project: %v\n", err)
http.Error(w, "error validating project", http.StatusInternalServerError)
return false
}
if !projectExists && shouldErr {
log.Println("project does not exist in org")
http.Error(w, "project does not exist in org", http.StatusNotFound)
return false
}
return projectExists
}
func authorizeProjectRename(w http.ResponseWriter, projectId string, auth *types.ServerAuth) bool {
if !authorizeProject(w, projectId, auth) {
return false
}
if !auth.HasPermission(shared.PermissionRenameAnyProject) {
log.Println("User does not have permission to rename project")
http.Error(w, "User does not have permission to rename project", http.StatusForbidden)
return false
}
return trueView on GitHub (pinned to e2d772072e)
Solutions
- Verify the projectId in the request matches an existing project in the authenticated organization
- List projects via the org's projects endpoint and use a valid projectId
- Confirm the client is authenticated against the same org that owns the project
- If the project was recently deleted, recreate it or pick another project
Example fix
// before
await api.renameProject({ projectId: localStorage.projectId, name: 'new-name' });
// after
const projects = await api.listProjects();
const project = projects.find(p => p.id === localStorage.projectId);
if (!project) throw new Error(`Project ${localStorage.projectId} not found in org; refresh project list`);
await api.renameProject({ projectId: project.id, name: 'new-name' }); Defensive patterns
Strategy: validation
Validate before calling
async function ensureProjectExistsInOrg(orgId, projectId) {
const projects = await api.listProjects(orgId);
if (!projects.some(p => p.id === projectId)) {
throw new Error(`Project ${projectId} does not exist in org ${orgId}; refresh and pick a valid project`);
}
} Type guard
function isProjectNotFound(res) {
return res.status === 404 && res.headers.get('content-type')?.includes('text/plain');
} Try / catch
try {
const res = await fetch(`/api/projects/${projectId}/plans`, { headers: authHeaders });
if (res.status === 404) {
const text = await res.text();
if (text === 'project does not exist in org') {
// refresh project list, clear stale cached ID
await refreshProjectList();
return null;
}
}
return await res.json();
} catch (e) { throw e; } Prevention
- Always resolve projectId from a fresh list-projects call, never long-lived caches
- Include org scoping when storing/selecting project IDs in the client
- Purge or revalidate cached project IDs after delete operations
- Log the projectId and orgId together to catch cross-org mix-ups quickly
When it happens
Trigger: Calling any project-scoped endpoint (via authorizeProject, RenameProjectHandler, DeleteProjectHandler, ListPlansHandler) with a projectId that is not a row in the projects table for auth.OrgId — wrong ID, typo, deleted project, or project belonging to another org.
Common situations: Client caching a stale projectId after the project was deleted; using an ID from a different organization; a copy-paste or truncation error in the ID; switching orgs in the client but reusing the old project ID.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- error validating project membership: %v
- error checking if project exists: %v
- error validating project
- error validating plan membership
- no access to plan
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/3df420ae487ca1b2.
Report an issue: GitHub.