paperclipai/paperclip · error · Error
${detail.name} already has an env var named ${key}.
Error message
${detail.name} already has an env var named ${key}. What it means
Conflict guard in the secret-grant mutation: the caller tried to grant agent access via an env-var binding, but the target agent already has an environment variable with that key, which would collide in the generated runtime environment. The offending input is the requested env var key for that agent.
Source
Thrown at ui/src/pages/Secrets.tsx:4426
setAccessError(null);
}, [referenceId]);
function invalidateAfterChange(agentId: string) {
queryClient.invalidateQueries({ queryKey: queryKeys.agents.list(companyId) });
queryClient.invalidateQueries({ queryKey: queryKeys.agents.detail(agentId) });
if (reference.kind === "company") {
queryClient.invalidateQueries({ queryKey: queryKeys.secrets.usage(reference.secret.id) });
}
}
const grantMutation = useMutation({
mutationFn: async ({ agentId, key }: { agentId: string; key: string }) => {
// Re-fetch right before patching so we merge into the freshest env config.
const detail = await agentsApi.get(agentId, companyId);
const adapterConfig = { ...((detail.adapterConfig ?? {}) as Record<string, unknown>) };
const env = { ...((adapterConfig.env ?? {}) as Record<string, unknown>) };
if (env[key] !== undefined) {
throw new Error(`${detail.name} already has an env var named ${key}.`);
}
env[key] =
reference.kind === "company"
? { type: "secret_ref", secretId: reference.secret.id }
: { type: "user_secret_ref", key: reference.definition.key };
return agentsApi.update(
agentId,
{ adapterConfig: { ...adapterConfig, env }, replaceAdapterConfig: true },
companyId,
);
},
onSuccess: (agent, variables) => {
setSelectedAgentId("");
setEnvKey("");
setEnvKeyDirty(false);
setAccessError(null);
invalidateAfterChange(variables.agentId);
pushToast({ title: "Access granted", body: `${agent.name} now receives ${variables.key}`, tone: "success" });View on GitHub (pinned to a7e689b3c3)
Solutions
- Choose a different env var key, or update the existing env var with that name instead.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at ui/src/pages/Secrets.tsx:4426 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of paperclipai/paperclip@a7e689b3c3 (2026-08-18).
Data as JSON: /api/errors/24816af05da58c28.
Report an issue: GitHub.