{"record":{"id":"ef2cf621cef08a8c","repo":"iflytek/astron-agent","slug":"space-spacenameexists","errorCode":null,"errorMessage":"space.spaceNameExists","messagePattern":"space\\.spaceNameExists","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"console/frontend/src/components/space/space-modal/index.tsx","lineNumber":101,"sourceCode":"    },\n    edit: {\n      handler: editSpace,\n      postProcess: async () => {\n        // 编辑模式无需额外处理\n      },\n    },\n  };\n\n  const defaultSubmitHandle = async (data: Record<string, any>) => {\n    const checkParams = {\n      name,\n      id: mode === 'create' ? '' : initialData?.id,\n    };\n    const checkRes = await checkName(checkParams);\n\n    if (checkRes) {\n      console.log(t('space.spaceNameExists'));\n      throw new Error(t('space.spaceNameExists'));\n    }\n\n    // 🎯 使用策略模式统一处理\n    const currentHandler = modeHandlers[mode as keyof typeof modeHandlers];\n    const res: any = await currentHandler.handler({\n      ...initialData,\n      ...data,\n    });\n    await currentHandler.postProcess(res);\n  };\n\n  const handleSubmit = async () => {\n    try {\n      const values = await form.validateFields();\n      // 将头像地址添加到提交数据中\n      const submitData = {\n        ...values,\n        avatarUrl,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/components/space/space-modal/index.tsx#L83-L119","documentation":"defaultSubmitHandle in the space modal calls checkName before create/edit; when the space name is already taken, it throws Error(t('space.spaceNameExists')) so the form surfaces a duplicate-name validation failure to the user and aborts the submit.","triggerScenarios":"Creating a space whose name matches an existing space in the same scope, or renaming a space to a name already used by another space (checkParams includes id only in edit mode).","commonSituations":"Duplicate naming by team members, case/whitespace variants that still collide, stale form data resubmitted after the space was created in another tab.","solutions":["Choose a different, unique space name.","Check for hidden whitespace/case differences in the name field.","If the name is believed free, verify via the space list whether a soft-deleted space still holds the name.","Refresh the form and resubmit in case of stale duplicate detection."],"exampleFix":"// before\nconst name = values.name;\n// after\nconst name = values.name.trim();\nif (spaces.some(s => s.name.toLowerCase() === name.toLowerCase())) {\n  message.warning(t('space.spaceNameExists'));\n  return;\n}","handlingStrategy":"try-catch","validationCode":"const exists = spaces.some(s => s.name.trim().toLowerCase() === name.trim().toLowerCase());\nif (exists) { message.warning(t('space.spaceNameExists')); return; }","typeGuard":null,"tryCatchPattern":"try {\n  await submitSpace(params);\n} catch (e) {\n  if (e.message.includes('spaceNameExists')) {\n    form.setFields([{ name: 'name', errors: [t('space.spaceNameExists')] }]);\n  } else { throw e; }\n}","preventionTips":["Show inline uniqueness validation on blur, not only on submit.","Trim/normalize names before the checkName call.","Enforce unique constraints at the backend too."],"tags":["frontend","react","validation","uniqueness"],"backgroundTag":"file-already-exists","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}