{"record":{"id":"0c1805bb01578e1b","repo":"paperclipai/paperclip","slug":"probe-found-no-matching-anthropic-environment","errorCode":null,"errorMessage":"Probe found no matching Anthropic Environment","messagePattern":"Probe found no matching Anthropic Environment","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/managed-agent.ts","lineNumber":241,"sourceCode":"    const environment = await anthropicRequest(\n      key,\n      \"GET\",\n      `/v1/environments/${encodeURIComponent(options.environmentId)}`,\n    );\n    assertSafeManagedEnvironment(environment);\n    return environment;\n  }\n\n  const existing = resourceByProfile(\n    await listAll(key, \"/v1/environments\"),\n    options.profileKey,\n    \"Environment\",\n  );\n  if (existing) {\n    assertSafeManagedEnvironment(existing);\n    return existing;\n  }\n  if (options.probe) throw new Error(\"Probe found no matching Anthropic Environment\");\n\n  const environment = await anthropicRequest(key, \"POST\", \"/v1/environments\", {\n    name: `Paperclip · ${options.displayName}`,\n    description: \"Paperclip remote-agent environment: no network or added packages.\",\n    config: {\n      type: \"cloud\",\n      networking: {\n        type: \"limited\",\n        allow_mcp_servers: false,\n        allow_package_managers: false,\n        allowed_hosts: [],\n      },\n      packages: {\n        apt: [],\n        cargo: [],\n        gem: [],\n        go: [],\n        npm: [],","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/cli/src/commands/managed-agent.ts#L223-L259","documentation":"resolveEnvironment looks up an Anthropic cloud Environment matching the Paperclip profile (by explicit environmentId or by profile metadata). When options.probe is set, the function runs in dry-run mode: it must NOT create anything, so if no matching environment exists it throws instead of POSTing a new one. This is the probe contract failing because the remote resource has not been provisioned yet.","triggerScenarios":"Calling the `environment` or `agent` CLI command with --probe (or options.probe=true) when no environmentId is given and no existing /v1/environments entry carries the profile's paperclip_profile metadata matching options.profileKey.","commonSituations":"Pre-flight validation against a fresh Anthropic account/workspace before the first real setup; pointing the CLI at a different API key or workspace than the one where the environment was created; the environment having been deleted or its metadata changed.","solutions":["Run the command without --probe once so Paperclip creates the Environment, then use --probe afterwards.","Pass --environment-id with the ID of the existing environment you want to reuse.","Verify the ANTHROPIC API key belongs to the workspace that contains the environment (list GET /v1/environments to confirm).","If the environment was deleted, recreate it via a non-probe run."],"exampleFix":"// before (fails in dry-run on a fresh workspace)\ncli managed-agent environment --probe\n// after (provision, then probe)\ncli managed-agent environment      # creates the Environment\ncli managed-agent environment --probe   # now passes","handlingStrategy":"validation","validationCode":"// before probing, confirm the environment exists for this profile\nconst envs = await listAll(key, \"/v1/environments\");\nconst match = resourceByProfile(envs, profileKey, \"Environment\");\nif (!match && probeOnly) throw new SkipProbeError(\"no environment for profile \" + profileKey);","typeGuard":"function hasId(r: unknown): r is Record<string, unknown> & { id: string } {\n  return typeof r === \"object\" && r !== null && typeof (r as any).id === \"string\" && (r as any).id.length > 0;\n}","tryCatchPattern":"try {\n  await resolveEnvironment(key, { ...opts, probe: true });\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"Probe found no matching\")) {\n    await resolveEnvironment(key, { ...opts, probe: false }); // provision then re-probe later\n  } else throw e;\n}","preventionTips":["Only use --probe against workspaces that have already been set up at least once.","Keep the same API key/workspace between setup and probe runs.","Store the created environmentId and pass it explicitly on subsequent runs.","Never delete or edit paperclip_profile metadata of managed environments."],"tags":["probe","dry-run","anthropic","environment","not-found"],"backgroundTag":"probe-found-no-matching-resource","analyzedSha":"5716fe907e596ce73501408fc6efdb19fb61edf2","analyzedAt":"2026-09-02T18:44:00.616Z","contentChangedAt":"2026-09-02T18:44:00.616Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}