plandex-ai/plandex · error

error validating project

Error message

error validating project

What it means

This 500 error is returned by authorizeProjectOptional when the db.ProjectExists(orgId, projectId) lookup fails with a real error (query failure, connection problem, etc.). It signals the server could not determine whether the project exists in the organization, not that the project is missing. It is a server-side infrastructure failure wrapped as an HTTP 500.

Source

Thrown at app/server/handlers/auth_helpers.go:628

	log.Printf("UserId: %s, Email: %s, OrgId: %s\n", authToken.UserId, user.Email, parsed.OrgId)

	return auth

}

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) {

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check server logs for the accompanying 'error validating project: %v' line to see the underlying database error
  2. Verify the database is reachable and the connection pool/credentials are correct
  3. Confirm the projectId sent by the client is well-formed (e.g., valid UUID) before hitting the API
  4. Ensure migrations for the projects table are applied in the target environment
  5. Retry the request once the DB issue is resolved; the error is transient when caused by connectivity

Example fix

// before (client treats any non-2xx as generic failure)
const res = await fetch(`/api/orgs/${orgId}/plans`);
// after (client surfaces the specific 500 from project validation)
const res = await fetch(`/api/orgs/${orgId}/plans`);
if (res.status === 500 && (await res.text()).includes('error validating project')) {
  console.error('DB error while validating project; check server logs / retry');
}
Defensive patterns

Strategy: retry

Validate before calling

function assertValidProjectId(projectId) {
  const uuidRe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
  if (!uuidRe.test(projectId)) throw new Error(`Malformed projectId: ${projectId}`);
}

Type guard

function isProjectLookupError(res) {
  return res.status === 500;
}

Try / catch

try {
  const res = await fetch(`/api/projects/${projectId}/plans`);
  if (res.status === 500) {
    // server-side DB failure validating the project: safe to retry after backoff
    await sleep(1000);
    return retryFetch();
  }
  return await res.json();
} catch (e) {
  console.error('Network failure during project authorization', e);
  throw e;
}

Prevention

When it happens

Trigger: Any handler that calls authorizeProject / ListPlansHandler / ListArchivedPlansHandler while db.ProjectExists returns a non-nil err: database connection failure, bad SQL/migration state, invalid projectId causing a query error, or DB timeout during project lookup.

Common situations: Postgres down or unreachable after a deploy; a malformed/non-UUID projectId string that breaks the query; connection pool exhaustion under load; schema drift where the projects table was renamed or a migration was not applied.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/2e00d628ced436eb. Report an issue: GitHub.