paperclipai/paperclip · error

Environment lease not found

Error message

Environment lease not found

What it means

404 sentinel on the environment lease read routes: getLeaseById returned no row for the requested leaseId, so no such lease exists in the instance.

Solutions

  1. Verify the id in the request path or body refers to an existing record in this company; re-list the parent collection to get a valid id.
  2. Check that the record was not deleted or archived, and that the request is scoped to the correct companyId.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/src/routes/environments.ts:1104 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-08-18). Data as JSON: /api/errors/6a548ea99b579dbe. Report an issue: GitHub.

Appendix: source

Thrown at server/src/routes/environments.ts:1105

    assertCanAccessInstanceEnvironments(req);
    const environment = await svc.getById(req.params.id as string);
    if (!environment) {
      res.status(404).json({ error: "Environment not found" });
      return;
    }
    // Metadata only (name / status / owning company) — never secret values.
    // Environments are instance-scoped while secrets are company-scoped, so
    // the editor needs this to render refs whose secret a given company's
    // picker cannot list. Gated by the same instance-level access check as
    // environment editing.
    const refs = await collectEnvironmentSecretRefs({ db, environment });
    res.json({ refs: await secrets.describeSecretRefs(refs) });
  });

  router.get("/environments/:id/leases", async (req, res) => {
    assertCanReadInstanceEnvironments(req);
    const environment = await svc.getById(req.params.id as string);
    if (!environment) {
      res.status(404).json({ error: "Environment not found" });
      return;
    }
    const leases = await svc.listLeases(environment.id, {
      status: req.query.status as string | undefined,
    });
    res.json(leases);
  });

  router.get("/environment-leases/:leaseId", async (req, res) => {
    assertCanReadInstanceEnvironments(req);
    const lease = await svc.getLeaseById(req.params.leaseId as string);
    if (!lease) {
      res.status(404).json({ error: "Environment lease not found" });
      return;
    }
    res.json(lease);
  });

View on GitHub (pinned to 01ad858492)