stablyai/orca · error · Error

Imported folder does not match the selected project identity

Error message

Imported folder does not match the selected project identity.

What it means

Thrown by alignRepoWithRequestedProject when the existing project-host setup's projectId differs from the requested projectId AND there is no provider identity that hashes to the requested project. getProjectIdForProviderIdentity(identity) must equal projectId — it formats as `github:<owner>/<repo>` (lowercased, normalized host). The check uses the project's stored providerIdentity or a caller-supplied requestedProviderIdentity as fallback.

Source

Thrown at src/main/ipc/repos.ts:259

    throw new Error(`Project setup was created without a project record: ${setup.projectId}`)
  }
  return { project, setup, repo }
}

function alignRepoWithRequestedProject(
  store: Store,
  repo: Repo,
  projectId: string,
  setupMethod: ProjectHostSetupExistingFolderArgs['setupMethod'] = 'imported-existing-folder',
  requestedProviderIdentity?: ProjectHostSetupExistingFolderArgs['projectProviderIdentity']
): ProjectHostSetupResult {
  let setup = getProjectHostSetupForRepo(store.getProjectHostSetups(), repo)
  if (setup.projectId !== projectId) {
    const project = store.getProjects().find((entry) => entry.id === projectId)
    // Why: the selected project can exist only on the source host, so its structured identity travels with the request.
    const identity = project?.providerIdentity ?? requestedProviderIdentity
    if (!identity || getProjectIdForProviderIdentity(identity) !== projectId) {
      throw new Error('Imported folder does not match the selected project identity.')
    }
    // Why: stamp the selected project's provider identity when the folder lacks upstream, so projection can merge it.
    const updated = store.updateRepo(repo.id, {
      upstream: {
        owner: identity.owner,
        repo: identity.repo,
        ...(identity.host ? { host: identity.host } : {})
      }
    })
    if (!updated) {
      throw new Error(`Project setup repo disappeared before it could be linked: ${repo.id}`)
    }
    repo = updated
    setup = getProjectHostSetupForRepo(store.getProjectHostSetups(), repo)
  }
  const updated = store.updateRepo(repo.id, { projectHostSetupMethod: setupMethod })
  if (!updated) {
    throw new Error(

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Pass a requestedProviderIdentity whose owner/repo/host hash to the requested projectId (verify with getProjectIdForProviderIdentity).
  2. Re-add the project record on the source host so the stored providerIdentity resolves, then retry the folder link.
  3. Confirm the projectId encoding matches: it must be `github:<lowercased-owner>/<lowercased-repo>` with ssh.github.com normalized to github.com.
  4. If the folder was mis-linked, clear its existing projectHostSetup before retrying so setup.projectId === projectId on entry.
Defensive patterns

Strategy: validation

Validate before calling

import { getProjectIdForProviderIdentity } from '../../shared/project-host-setup-projection'
import type { ProjectProviderIdentity } from '../../shared/types'

function folderIdentityMatchesRequestedProject(
  identity: ProjectProviderIdentity | undefined,
  projectId: string
): boolean {
  return !!identity && getProjectIdForProviderIdentity(identity) === projectId
}

Type guard

function isFolderProjectIdentityMismatch(err: unknown): boolean {
  return err instanceof Error && err.message === 'Imported folder does not match the selected project identity.'
}

Try / catch

try {
  await linkFolderToProject(store, repo, projectId, setupMethod, requestedProviderIdentity)
} catch (err) {
  if (isFolderProjectIdentityMismatch(err)) {
    surfaceUserAction('The folder is linked to a different project. Re-add it under that project, or supply a provider identity matching the selected one.')
    return
  }
  throw err
}

Prevention

When it happens

Trigger: Importing/linking an existing folder whose recorded setup points at project A, while the caller requests it be linked to project B, and neither the stored project record nor the request supplies an identity that hashes to B's id. Concretely: setup.projectId !== projectId AND (!identity || getProjectIdForProviderIdentity(identity) !== projectId).

Common situations: Folder was previously linked to a different GitHub project; project record deleted from the source host so providerIdentity is undefined; requestedProviderIdentity owner/repo typo that hashes to a different id; host/owner/repo case mismatch in the identity vs the projectId encoding.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/14eb7572652892cf. Report an issue: GitHub.