{"record":{"id":"529d6296b43ec9ef","repo":"iflytek/astron-agent","slug":"t-space-teamnameexists-enterprisetype","errorCode":null,"errorMessage":"t('space.teamNameExists', { enterpriseType })","messagePattern":"t\\('space\\.teamNameExists', (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"console/frontend/src/pages/space/team-create/index.tsx","lineNumber":69,"sourceCode":"  // 触发上传\n  const triggerFileSelectPopup = (callback: () => void) => {\n    setTriggerChild(false);\n    callback();\n  };\n\n  const handleCreateTeam = async () => {\n    const name = teamName.trim();\n    if (!name) {\n      message.error(textConfig.emptyTip);\n      return;\n    }\n\n    setLoading(true);\n    try {\n      const checkRes = await checkEnterpriseName({ name });\n\n      if (checkRes) {\n        throw new Error(textConfig.existTip);\n      }\n\n      const res: any = await createEnterprise({\n        name,\n        avatarUrl: logoUrl,\n      });\n\n      message.success(textConfig.createSuccessTip);\n      await getJoinedEnterpriseList();\n      handleTeamSwitch(res);\n    } catch (error: any) {\n      message.error(error?.message || error?.msg || textConfig.createFailedTip);\n    } finally {\n      setLoading(false);\n    }\n  };\n\n  return (","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/pages/space/team-create/index.tsx#L51-L87","documentation":"Team creation validates the proposed name with checkEnterpriseName(); if the backend reports the name is already taken, handleCreateTeam throws Error(textConfig.existTip), which resolves to t('space.teamNameExists', { enterpriseType }) — a localized 'team/enterprise name already exists' message. The thrown error propagates to form/error handling so the user can pick a different name.","triggerScenarios":"Submitting the team-create form with a name that already exists in the current tenant/space: checkEnterpriseName({ name }) returns truthy and the handler throws before calling createEnterprise.","commonSituations":"Two users creating similarly named teams concurrently; retrying a submission after a previous create partially succeeded; case/whitespace differences not counted by the checker but blocked by backend; stale form state resubmitting an old name.","solutions":["Choose a different team name and resubmit — this is an expected, user-facing conflict.","Pre-validate on blur/input with a debounced checkEnterpriseName call to surface conflicts before submit.","Verify the i18n key 'space.teamNameExists' exists for all locales so the message renders instead of the raw key.","If a false positive, confirm checkEnterpriseName scopes the uniqueness check to the correct space/tenant."],"exampleFix":"// before\nconst checkRes = await checkEnterpriseName({ name });\nif (checkRes) {\n  throw new Error(textConfig.existTip);\n}\n\n// after\nconst checkRes = await checkEnterpriseName({ name: name.trim() });\nif (checkRes) {\n  form.setFields([{ name: 'name', errors: [textConfig.existTip] }]);\n  setLoading(false);\n  return; // surface as form error instead of uncaught throw\n}","handlingStrategy":"validation","validationCode":"// before submit\nconst res = await checkEnterpriseName({ name: name.trim() });\nif (res) {\n  form.setFields([{ name: 'name', errors: [textConfig.existTip] }]);\n  return;\n}","typeGuard":"function nameIsAvailable(res: unknown): boolean {\n  return !res; // truthy response means name taken\n}","tryCatchPattern":"try {\n  await handleCreateTeam(values);\n} catch (e) {\n  message.error(e.message); // surfaces localized 'name exists' tip\n  setLoading(false);\n}","preventionTips":["Debounce-check the name on field blur to catch conflicts before submit.","Always trim/normalize the name before uniqueness checks.","Confirm the i18n key space.teamNameExists exists in every locale file.","Show a success-safe reset so retries don't resubmit stale names."],"tags":["i18n","validation","duplicate-resource","form"],"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-19T12:17:13.211Z"}