{"record":{"id":"d3010b462332715d","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"skill-create-failed-createenv-code","errorCode":null,"errorMessage":"skill create failed: ${createEnv.code}","messagePattern":"skill create failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"MemoryPanel/src/panel/http/routes/meta/proxy.ts","lineNumber":403,"sourceCode":"          is_executable: entry.is_executable,\n        });\n      }\n    } catch {\n      /* 单个资源读取失败则跳过 */\n    }\n  }\n\n  const createEnv = await deps.skillKernel.invoke('create', {\n    user_id: userId,\n    team_id: teamId,\n    agent_id: targetAgentId,\n    name: detail.name,\n    content: detail.content,\n    resources: resources.length ? resources : undefined,\n    metadata: { forked_from: { skill_id: sourceSkillId, name: detail.name } },\n  }, ctx);\n  if (createEnv.code !== 0 && createEnv.code !== 42201) {\n    throw new Error(`skill create failed: ${createEnv.code}`);\n  }\n}\n\n/** 把 knowledge 资产（code_graph / wiki）引用绑定到 agent（list → append → set）。 */\nasync function allocateKnowledgeToAgent(\n  deps: PanelDeps,\n  ctx: MetaCallContext,\n  agentId: string,\n  assetId: string,\n  assetType: string,\n): Promise<void> {\n  const caller = await resolveCallerUserId(deps, ctx);\n  const listEnv = await deps.metaKernel.invoke('agent-fixed-asset/list', { agent_id: agentId }, ctx);\n  if (listEnv.code !== 0) return;\n  const bindings = extractListItems<{\n    asset_id: string;\n    asset_type: string;\n    injection_mode?: string;","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryPanel/src/panel/http/routes/meta/proxy.ts#L385-L421","documentation":"After fetching the source detail, forkSkillToAgent creates the new skill via a 'create' command in a forked environment. Non-zero codes abort the fork — except 42201, which is tolerated as an expected 'already exists' style response, so only genuinely failed creates throw.","triggerScenarios":"Creating the forked skill when the backend rejects it: duplicate name not covered by 42201, quota exceeded, invalid manifest/resources payload, or permission failure for the target team.","commonSituations":"Forking twice with the same target name where backend returns a code other than 42201; team skill quota reached; oversized skill content rejected by the backend; name collisions with special characters.","solutions":["Log createEnv.code with stderr to find the backend's rejection reason","Rename the target skill (or pre-delete the existing one) if it's a duplicate-name issue","Check team/user skill quota and free a slot before retrying","If 42201-equivalent duplicates should be tolerated, extend the accepted code list after confirming semantics"],"exampleFix":"// before\nif (createEnv.code !== 0 && createEnv.code !== 42201) {\n  throw new Error(`skill create failed: ${createEnv.code}`);\n}\n// after\nif (createEnv.code !== 0 && createEnv.code !== 42201) {\n  throw new Error(`skill create failed: ${createEnv.code} (${createEnv.stderr ?? 'no detail'})`);\n}","handlingStrategy":"try-catch","validationCode":"const dup = await skillsApi.findByName({ name: detail.name, team_id: teamId });\nif (dup) throw new Error(`skill name already taken: ${detail.name}`);","typeGuard":null,"tryCatchPattern":"try { await forkSkillToAgent(...); } catch (e) { if (e.message.startsWith('skill create failed:')) { logger.error(`fork create rejected (${e.message}); check duplicate names, quota, permissions`); } else throw e; }","preventionTips":["Generate unique target skill names (suffix with agent id/timestamp) to avoid duplicate rejections","Check team skill quota before forking","Document which backend codes (like 42201) are tolerated and treat others as actionable failures"],"tags":["skill-fork","ipc","error-code"],"backgroundTag":"subcommand-nonzero-exit","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}