{"record":{"id":"802c151f37d07237","repo":"paperclipai/paperclip","slug":"secret-create-returned-no-data-for-candidate-sec","errorCode":null,"errorMessage":"Secret create returned no data for ${candidate.secretName}","messagePattern":"Secret create returned no data for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/secrets.ts","lineNumber":330,"sourceCode":"    const agent = agents.find((row) => row.id === candidate.agentId);\n    const env = asRecord(agent?.adapterConfig.env);\n    const value = env ? toPlainEnvValue(env[candidate.envKey]) : null;\n    if (!value) continue;\n\n    if (candidate.existingSecretId) {\n      await ctx.api.post(apiPath`/api/secrets/${candidate.existingSecretId}/rotate`, { value });\n      createdOrRotated.set(`${candidate.agentId}:${candidate.envKey}`, candidate.existingSecretId);\n      rotatedSecrets += 1;\n      continue;\n    }\n\n    const created = await ctx.api.post<CompanySecret>(apiPath`/api/companies/${companyId}/secrets`, {\n      name: candidate.secretName,\n      provider: \"local_encrypted\",\n      value,\n      description: `Migrated from agent ${candidate.agentId} env ${candidate.envKey}`,\n    });\n    if (!created) throw new Error(`Secret create returned no data for ${candidate.secretName}`);\n    createdOrRotated.set(`${candidate.agentId}:${candidate.envKey}`, created.id);\n    createdSecrets += 1;\n  }\n\n  let updatedAgents = 0;\n  for (const agent of agents) {\n    const env = asRecord(agent.adapterConfig.env);\n    if (!env) continue;\n    const secretIdByEnvKey = new Map<string, string>();\n    for (const [key] of Object.entries(env)) {\n      const secretId = createdOrRotated.get(`${agent.id}:${key}`);\n      if (secretId) secretIdByEnvKey.set(key, secretId);\n    }\n    if (secretIdByEnvKey.size === 0) continue;\n    const adapterConfig = {\n      ...agent.adapterConfig,\n      env: buildMigratedAgentEnv(env, secretIdByEnvKey),\n    };","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/client/secrets.ts#L312-L348","documentation":"During secret migration, the code POSTs to `/api/companies/<companyId>/secrets` to create a company secret and expects a `CompanySecret` body back. If the API returns a falsy value (null/undefined), it throws naming the candidate secret. Unlike the input-validation errors above, this fires after a successful-looking API call that returned no payload — pointing at the server, transport, or response shape rather than the CLI flags.","triggerScenarios":"The create endpoint returns 2xx with an empty/null body; a proxy/load-balancer strips the body; a server bug or version mismatch returns no entity; the secret was actually created but the response omitted it.","commonSituations":"API version skew between CLI and server; a reverse proxy buffering/emptying the response; transient server error masked by a 200; the server rejecting the payload silently.","solutions":["Re-run `paperclipai secrets list -C <companyId>` to check whether the secret was actually created despite the null response","Check the server logs around the create request for the named secret","Verify CLI and server versions are compatible for the secrets create contract","If a proxy is involved, confirm it forwards response bodies unchanged"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Post-call sanity check before relying on the created secret\nasync function createSecretOrFail(api: { post<T>(p: string, body: unknown): Promise<T | null> }, path: string, body: unknown) {\n  const created = await api.post(path, body);\n  if (!created) throw new Error(`Secret create returned no data for ${(body as any).name}`);\n  return created;\n}","typeGuard":"import type { CompanySecret } from \"@paperclipai/shared\";\nfunction isCompanySecret(v: unknown): v is CompanySecret {\n  return typeof v === \"object\" && v !== null && typeof (v as CompanySecret).id === \"string\";\n}","tryCatchPattern":"try {\n  const created = await ctx.api.post(`/api/companies/${companyId}/secrets`, body);\n  if (!created) throw new Error(`Secret create returned no data for ${body.name}`);\n} catch (err) {\n  console.error(`Secret create failed; verify with 'secrets list'. ${err instanceof Error ? err.message : err}`);\n  process.exit(1);\n}","preventionTips":["After a null-response error, verify with `secrets list` whether the secret was actually created","Keep CLI and server versions aligned for the secrets contract","Suspect proxies/load balancers that may strip response bodies"],"tags":["cli","secrets","api","migration","runtime"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}