#1949

[Bug]: Scoped/restricted account gets a hard error on the projects home page: authorize() throws "project '*' not found" because the cross-org hint lookup is missing its scoped-token guard

OpenLiamRRopened 2d ago

Existing issue

  • I have searched the existing issues and found no duplicate.

Problem description

A restricted/scoped account cannot load its own projects home page. The page comes back empty (0 projects shown) and the browser console shows repeated 404s, including a toast referencing project '' not found. The server logs show the exact exception: an internal "cross-org hint" computation in getProjectHome calls authorization.authorize() with a literal resourceId of "" as a sentinel for "the whole collection," but for a restricted-role context authorize() instead tries to resolve "*" as a real project id, finds nothing, and throws NotFoundError. That exception is not caught, so it fails the whole request instead of just skipping the hint.

Steps to reproduce

  1. As an org admin, invite a user and restrict their access to a specific set of projects (not org-wide), e.g. 3 named projects with "Deploy & manage".
  2. Sign in as that restricted user.
  3. Load the dashboard home / projects page.
  4. Observe: 0 projects shown, repeated 404s in the browser console (/api/proxy/api/projects/home and others), and a toast referencing project '*' not found.

Environment

  • Openship version: 1.0.1 (self-hosted)
  • Account type: a dashboard user invited with restricted access to specific projects (deploy and manage on 3 named projects, no org-wide access)
  • Affected endpoint: GET /api/projects/home (called by the frontend as /api/proxy/api/projects/home), also observed intermittently on /api/github/home

Logs and screenshots

Server log (openship-api-1), full event:


{"schemaVersion":1,"eventId":"d5076b44-0cce-4dad-a4eb-705e00cd1b68",
 "timestamp":"2026-12-02T09:26:28.741Z","category":"not_found","severity":"warn",
 "error":{"name":"NotFoundError","message":"project '*' not found","code":"NOT_FOUND",
  "stack":"    at Object.authorize (/app/packages/platform/src/authorization.ts:365:26)\n    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)\n    at async <anonymous> (/app/packages/platform/src/engine/modules/projects/project-home.operations.ts:119:27)\n    at async Promise.all (index 0)\n    at async getProjectHome (/app/packages/platform/src/engine/modules/projects/project-home.operations.ts:117:19)\n    at async Object.getHome (/app/packages/platform/src/projects.ts:244:55)\n    at async getHome (/app/apps/api/dist/chunk-EUUO6SMP.js:5084:19)"},
 "context":{"organizationId":"org_usr__DUuy278vd047uKb","userId":"usr__DUuy278vd047uKb",
  "resourceType":"project","resourceId":"*","method":"GET","code":"NOT_FOUND",
  "route":"/api/projects/:id",
  "summary":"[projects.getHome] cross-org hint lookup failed:"}}


The source at `packages/platform/src/engine/modules/projects/project-home.operations.ts` (around line 100-120):


// Compute "projects in other orgs" -- used by the dashboard when this
// org has 0 projects to nudge "your projects are over there". Cheap
// query: one count per other org. Only runs when current org list is
// empty so the normal case has no extra cost.
let otherOrgs = [];
// Never surface cross-org hints to a scoped token -- it must see nothing
// outside the projects it owns, including counts in the user's other orgs.
if (accountView && result.total === 0) {
  try {
    const memberships = await repos.member.listByUser(userId);
    const otherOrgIds = memberships
      .map((m) => m.organizationId)
      .filter((id) => id !== organizationId);
    const orgs = await repos.organization.findManyById(otherOrgIds).catch(...);
    const orgsById = new Map(orgs.map((o) => [o.id, o]));
    otherOrgs = await Promise.all(
      otherOrgIds.map(async (otherOrgId) => {
        const context = await authorization.authorize({ ...ctx, organizationId: otherOrgId, scopeMode: "fixed" }, {
          resourceType: "project", resourceId: "*", action: "read", scope: "list",
        });
        const countResult = await projectService
          .listProjects(otherOrgId, { page: 1, perPage: 1, ... })
          .catch(...);
        ...
      }),
    );
  }
  ...
}


The comment states the intended behavior correctly ("Never surface cross-org hints to a scoped token"), but the `if` condition that gates this whole block only checks `accountView && result.total === 0`. There is no check that excludes a restricted/scoped token, so the guard described in the comment was never actually implemented.

`authorization.authorize()` is called with `resourceId: "*"` as a sentinel meaning "the collection" for a list-scope permission check. For a restricted-role context specifically, this hits a code path in `authorize()` (authorization.ts:365) that resolves `resourceId` as a literal project id, finds no project named `*`, and throws. Unlike the `listProjects` call two lines below it, this `authorize()` call has no `.catch()`, so the exception propagates out of the `Promise.all`, out of `getProjectHome`, and fails the whole `/api/projects/home` request instead of just omitting the cross-org hint.

Additional context

Expected

A restricted/scoped account loads its home/projects page and sees exactly the projects it was granted (3 in our case), with no cross-org hint computed at all, and no error.

Actual

The request throws NotFoundError: project '*' not found from inside the cross-org hint computation. The frontend surfaces this as a failed projects list and repeated 404s, and the restricted account cannot see or use any of its granted projects from the dashboard.

Suggested fix

Add the missing scoped-token check to the if condition so this block is skipped entirely for a restricted/scoped context, matching the existing comment's stated intent, e.g.:

if (accountView && result.total === 0 && context.role !== "restricted") {

As a defensive backstop, also wrap the authorization.authorize(...) call in a .catch() the same way the adjacent listProjects call already is, so a future case like this degrades to "no hint" instead of failing the whole request.

Impact

Any dashboard user invited with restricted/scoped access to specific projects (rather than org-wide access) cannot load their own projects home page at all when their granted-project count nets out to "0 in current org" in this check. This blocks the documented restricted-access workflow entirely for affected accounts.

Related

Unrelated background noise seen in the same log window, not connected to this bug: recurring GitHub API error (403): Resource not accessible by integration from the github:deployment-checks worker, which looks like a separate GitHub App permissions/Checks API issue.

Activity

0

No activity yet.