{"record":{"id":"a5faaea9a0f91aa3","repo":"different-ai/openwork","slug":"enter-an-organization-name","errorCode":null,"errorMessage":"Enter an organization name.","messagePattern":"Enter an organization name\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ee/apps/den-web/app/(den)/dashboard/_providers/org-dashboard-provider.tsx","lineNumber":426,"sourceCode":"          ...retryAfterReauth,\n          ...queuedDuringRetry,\n        ];\n        setReauthDialogOpen(true);\n        return;\n      }\n\n      queuedActions = queuedDuringRetry;\n    }\n  }\n\n  async function createOrganization(name: string) {\n    if (isSingleOrgMode) {\n      throw new Error(\"This deployment uses one managed organization.\");\n    }\n\n    const trimmed = name.trim();\n    if (!trimmed) {\n      throw new Error(\"Enter an organization name.\");\n    }\n\n    setMutationBusy(\"create-organization\");\n    setOrgError(null);\n    try {\n      const { response, payload } = await requestJson(\n        \"/v1/org\",\n        {\n          method: \"POST\",\n          body: JSON.stringify({ name: trimmed }),\n        },\n        12000,\n      );\n\n      if (!response.ok) {\n        throw new Error(getErrorMessage(payload, `Failed to create organization (${response.status}).`));\n      }\n","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_providers/org-dashboard-provider.tsx#L408-L444","documentation":"createOrganization throws this synchronous validation error when the supplied name is empty after trimming (name.trim() === \"\"). It is a client-side guard that fires before any network call and before the mutation-busy state is set.","triggerScenarios":"Calling createOrganization(\"\") or createOrganization(\"   \"); a form submitting with a whitespace-only input; programmatic calls passing an uninitialized string variable.","commonSituations":"Users pressing Enter in an empty create-org dialog; an uncontrolled form input whose defaultValue never synced to state; e2e scripts sending blank names.","solutions":["Validate the name in the form/UI before calling createOrganization (required-field check with minLength).","Trim input at the form layer so trailing spaces don't silently produce this error.","Catch the error and focus the name input with an inline validation message.","Disable the submit button while the trimmed name is empty."],"exampleFix":"// before\nawait createOrganization(nameInput.value);\n// after\nconst trimmed = nameInput.value.trim();\nif (!trimmed) {\n  setNameFieldError(\"Enter an organization name.\");\n  return;\n}\nawait createOrganization(trimmed);","handlingStrategy":"validation","validationCode":"function canCreateOrg(name: string): boolean {\n  return name.trim().length > 0;\n}\nif (!canCreateOrg(input)) disableSubmit();","typeGuard":null,"tryCatchPattern":"try {\n  await createOrganization(name);\n} catch (err) {\n  if (err.message === \"Enter an organization name.\") {\n    focusNameInputWithError(err.message);\n  } else throw err;\n}","preventionTips":["Trim input values at the form layer before submit.","Make the name field required with minLength validation.","Disable the submit button while the trimmed name is empty.","Autofocus the field when the dialog opens to avoid accidental empty submits.","Add e2e coverage for the empty-name submission path."],"tags":["validation","input","den-web"],"backgroundTag":"invalid-input-validation","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}