{"record":{"id":"a33c441fd3574db8","repo":"paperclipai/paperclip","slug":"managed-profile-unavailable","errorCode":"managed_profile_unavailable","errorMessage":"The selected Claude Managed profile is not fully qualified on this Runner Lab server.","messagePattern":"The selected Claude Managed profile is not fully qualified on this Runner Lab server\\.","errorType":"http","errorClass":"RouteError","httpStatus":503,"severity":"error","filePath":"packages/paperclip-runner/scripts/capability-issue-thread-server.mjs","lineNumber":311,"sourceCode":"    ...(provider === \"claude_managed\" ? { managedProfileId, maxSessionListCostUsd } : {}),\n    ...(provider === \"aws_agentcore\" ? { agentCoreProfileId, maxEstimatedSessionCostUsd } : {}),\n    lifecyclePolicy,\n  };\n}\n\nfunction resolveManagedProfile(configuration) {\n  const profileId = process.env.PAPERCLIP_CLAUDE_MANAGED_PROFILE_ID?.trim() || configuration.managedProfileId;\n  if (profileId !== configuration.managedProfileId) {\n    throw new RouteError(400, \"managed_profile_not_found\", \"The selected Claude Managed profile is not configured on this Runner Lab server.\");\n  }\n  const anthropicAgentId = process.env.ANTHROPIC_MANAGED_AGENT_ID?.trim();\n  const agentVersion = process.env.ANTHROPIC_MANAGED_AGENT_VERSION?.trim();\n  const environmentId = process.env.ANTHROPIC_MANAGED_ENVIRONMENT_ID?.trim();\n  const canonicalAgentVersion = agentVersion !== undefined\n    && /^[1-9][0-9]*$/.test(agentVersion)\n    && BigInt(agentVersion) <= 2_147_483_647n;\n  if (!process.env.ANTHROPIC_API_KEY || !profileId || !anthropicAgentId || !canonicalAgentVersion || !environmentId) {\n    throw new RouteError(\n      503,\n      \"managed_profile_unavailable\",\n      \"The selected Claude Managed profile is not fully qualified on this Runner Lab server.\",\n    );\n  }\n  return {\n    profileId,\n    anthropicAgentId,\n    agentVersion,\n    environmentId,\n    betaVersion: \"managed-agents-2026-04-01\",\n    maxSessionListCostUsd: configuration.maxSessionListCostUsd,\n  };\n}\n\nfunction resolveAgentCoreProfile(configuration) {\n  const required = (name) => {\n    const value = process.env[name]?.trim();","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/packages/paperclip-runner/scripts/capability-issue-thread-server.mjs#L293-L329","documentation":"After the profile ID matches, resolveManagedProfile verifies the server is fully qualified to run Claude Managed: ANTHROPIC_API_KEY, a non-empty profile ID, ANTHROPIC_MANAGED_AGENT_ID, an ANTHROPIC_MANAGED_AGENT_VERSION that is a positive integer fitting in a signed 32-bit int, and ANTHROPIC_MANAGED_ENVIRONMENT_ID must all be present. If any is missing or invalid it throws 503 managed_profile_unavailable, signaling a server-side provisioning gap rather than a bad client request.","triggerScenarios":"Any of: ANTHROPIC_API_KEY unset; PAPERCLIP_CLAUDE_MANAGED_PROFILE_ID/configured profile empty; ANTHROPIC_MANAGED_AGENT_ID missing; ANTHROPIC_MANAGED_AGENT_VERSION absent, non-numeric, zero-prefixed, 0, negative, or > 2147483647; ANTHROPIC_MANAGED_ENVIRONMENT_ID missing.","commonSituations":"Fresh Runner Lab server provisioned without running the managed-profile setup; credentials rotated and API key removed from the environment; agent version bumped to a value exceeding the 32-bit guard; env file partially sourced so only some ANTHROPIC_MANAGED_* vars load.","solutions":["Set ANTHROPIC_API_KEY in the server environment and restart the Runner Lab server.","Set ANTHROPIC_MANAGED_AGENT_ID, ANTHROPIC_MANAGED_AGENT_VERSION (a positive integer ≤ 2147483647), and ANTHROPIC_MANAGED_ENVIRONMENT_ID to the values produced by the managed-profile provisioning step.","Re-run the server's managed profile provisioning/lab setup script to regenerate all required env vars.","Verify the env file actually loads (e.g. all vars exported) and the version string contains only digits with no leading zeros."],"exampleFix":"// before\nANTHROPIC_API_KEY=sk-...\n# ANTHROPIC_MANAGED_AGENT_VERSION unset\n// after\nANTHROPIC_API_KEY=sk-...\nANTHROPIC_MANAGED_AGENT_ID=agent-42\nANTHROPIC_MANAGED_AGENT_VERSION=3\nANTHROPIC_MANAGED_ENVIRONMENT_ID=env-7","handlingStrategy":"validation","validationCode":"function claudeManagedReady(env = process.env) {\n  const v = env.ANTHROPIC_MANAGED_AGENT_VERSION?.trim() ?? \"\";\n  return Boolean(\n    env.ANTHROPIC_API_KEY?.trim() &&\n    env.PAPERCLIP_CLAUDE_MANAGED_PROFILE_ID?.trim() &&\n    env.ANTHROPIC_MANAGED_AGENT_ID?.trim() &&\n    (/^[1-9][0-9]*$/.test(v) && BigInt(v) <= 2147483647n) &&\n    env.ANTHROPIC_MANAGED_ENVIRONMENT_ID?.trim()\n  );\n}\nif (!claudeManagedReady()) await runManagedProfileProvisioning();","typeGuard":"function isValidAgentVersion(v) {\n  return typeof v === \"string\" && /^[1-9][0-9]*$/.test(v.trim()) && BigInt(v.trim()) <= 2147483647n;\n}","tryCatchPattern":"try {\n  await configureHarness(cfg);\n} catch (e) {\n  if (e.code === \"managed_profile_unavailable\") {\n    // 503: server-side gap; surface to operator, do not blind-retry\n    reportServerMisconfiguration(e.message);\n  } else throw e;\n}","preventionTips":["Add a server health/readiness check that asserts all ANTHROPIC_MANAGED_* vars before accepting requests.","Export the full env block produced by provisioning as a unit; never rotate one var alone.","Validate the agent version fits a 32-bit positive integer when bumping it.","Use a process manager env_file so partially sourced shells cannot drop vars."],"tags":["env-var","server-config","anthropic","http-503"],"backgroundTag":"missing-env-var","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"}