paperclipai/paperclip · error · EnvironmentRunError

environment_not_found

environment_not_found

Error message

Environment "${environmentId}" not found.

What it means

EnvironmentRunError('environment_not_found') from resolveEnvironment: the selected environment id does not match the local fallback and environmentsSvc.getById returned no row. The run cannot proceed against a nonexistent environment; environmentId is attached to the error.

Source

Thrown at server/src/services/environment-run-orchestrator.ts:182

  /**
   * Resolve the selected environment for a run. The caller passes the concrete
   * selected environment id plus the built-in local fallback id used to lazily
   * ensure the local environment row exists.
   */
  async function resolveEnvironment(input: {
    companyId: string;
    selectedEnvironmentId: string;
    localEnvironmentId: string;
  }): Promise<Environment> {
    const environmentId = input.selectedEnvironmentId || input.localEnvironmentId;

    const environment =
      environmentId === input.localEnvironmentId
        ? await environmentsSvc.ensureLocalEnvironment(input.companyId)
        : await environmentsSvc.getById(environmentId);

    if (!environment) {
      throw new EnvironmentRunError("environment_not_found", `Environment "${environmentId}" not found.`, {
        environmentId,
      });
    }

    if (environment.status !== "active") {
      throw new EnvironmentRunError("environment_inactive", `Environment "${environment.name}" is not active (status: ${environment.status}).`, {
        environmentId: environment.id,
        driver: environment.driver,
      });
    }

    return environment;
  }

  /**
   * Acquire an environment lease for a heartbeat run.
   * Wraps the runtime driver's acquire call with standardized error handling.
   */

View on GitHub (pinned to 120ae5428f)

Solutions

  1. Verify the environment id exists for the company; create the environment first if needed.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/src/services/environment-run-orchestrator.ts:182 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/04facc57f49cf97e. Report an issue: GitHub.