{"record":{"id":"01410e16b924687b","repo":"SonarSource/sonarqube","slug":"project-s-not-found","errorCode":null,"errorMessage":"Project '%s' not found","messagePattern":"Project '(.+?)' not found","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java","lineNumber":96,"sourceCode":"  public EntityDto getEntityByKey(DbSession dbSession, String entityKey) {\n    return dbClient.entityDao().selectByKey(dbSession, entityKey)\n      .orElseThrow(() -> new NotFoundException(String.format(LABEL_ENTITY_NOT_FOUND, entityKey)));\n  }\n\n  public EntityDto getEntityByUuid(DbSession dbSession, String entityUuid) {\n    return dbClient.entityDao().selectByUuid(dbSession, entityUuid)\n      .orElseThrow(() -> new NotFoundException(String.format(LABEL_ENTITY_NOT_FOUND, entityUuid)));\n  }\n\n  public ProjectDto getProjectByKey(DbSession dbSession, String projectKey) {\n    return dbClient.projectDao().selectProjectByKey(dbSession, projectKey)\n      .orElseThrow(() -> new NotFoundException(String.format(LABEL_PROJECT_NOT_FOUND, projectKey)));\n  }\n\n  public ProjectDto getProjectByKeyAndPermission(DbSession dbSession, String projectKey, UserSession userSession, ProjectPermission permission) {\n    ProjectDto project = getProjectByKey(dbSession, projectKey);\n    if (!userSession.hasEntityPermission(permission, project)) {\n      throw new NotFoundException(String.format(LABEL_PROJECT_NOT_FOUND, projectKey));\n    }\n    return project;\n  }\n\n  public ProjectDto getApplicationByKey(DbSession dbSession, String applicationKey) {\n    return dbClient.projectDao().selectApplicationByKey(dbSession, applicationKey)\n      .orElseThrow(() -> new NotFoundException(String.format(\"Application '%s' not found\", applicationKey)));\n  }\n\n  public ProjectDto getProjectOrApplicationByKey(DbSession dbSession, String projectKey) {\n    return dbClient.projectDao().selectProjectOrAppByKey(dbSession, projectKey)\n      .orElseThrow(() -> new NotFoundException(String.format(LABEL_PROJECT_NOT_FOUND, projectKey)));\n  }\n\n  public ProjectDto getProjectByUuid(DbSession dbSession, String projectUuid) {\n    return dbClient.projectDao().selectByUuid(dbSession, projectUuid)\n      .filter(p -> ComponentQualifiers.PROJECT.equals(p.getQualifier()))\n      .orElseThrow(() -> new NotFoundException(String.format(LABEL_PROJECT_NOT_FOUND, projectUuid)));","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java#L78-L114","documentation":"ComponentFinder.getProjectByKeyAndPermission looks up a project by key and then checks the user's permission. Both 'project does not exist' and 'you lack the given ProjectPermission' raise the same NotFoundException 'Project <key> not found' — it deliberately does not reveal whether the project exists.","triggerScenarios":"api call with a wrong project key, or a valid key where the current user lacks the required permission (e.g. admin, scan).","commonSituations":"Typo'd project keys; token of a user without project permissions; project deleted or key changed; using org-scoped keys without the organization parameter.","solutions":["Verify the project key exists via api/projects/search and matches exactly (case-sensitive)","Check the authenticated user/token has the required permission (api/permissions) or use an admin token","Confirm the project was not renamed/deleted; recreate or restore it if needed","Pass the correct organization parameter when using SonarCloud"],"exampleFix":"// before\nGET /api/projects/delete?project=my-projcet\n// after\nGET /api/projects/search?q=my-project  // confirm exact key first\nGET /api/projects/delete?project=my-project","handlingStrategy":"try-catch","validationCode":"// confirm existence AND permission before the destructive call\nconst res = await api.projects.search({ q: key });\nconst project = res.components.find(p => p.key === key);\nif (!project) throw new Error(`project ${key} not found or not visible to this token`);","typeGuard":null,"tryCatchPattern":"try {\n  await api.projects.delete({ project: key });\n} catch (e) {\n  if (e.status === 404 && /not found/.test(e.message)) {\n    // ambiguous: missing project OR insufficient permission\n    throw new Error(`Project '${key}' not found, or the token lacks the required permission`);\n  }\n  throw e;\n}","preventionTips":["Verify exact project keys from api/projects/search (case-sensitive)","Use tokens with the required project permission for automated jobs","Re-resolve keys after project renames; avoid storing keys in config without validation","Pass the organization parameter on SonarCloud"],"tags":["java","projects","not-found","permissions"],"backgroundTag":"record-not-found","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}