Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions apps/web/ce/components/projects/create/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const CreateProjectForm = observer(function CreateProjectForm(props: TCre
if (setToFavorite) {
handleAddToFavorites(res.id);
}
handleNextStep(res.id);
return handleNextStep(res.id);
})
.catch((err) => {
try {
Expand All @@ -119,8 +119,9 @@ export const CreateProjectForm = observer(function CreateProjectForm(props: TCre

const nameError = errorData.name?.includes("PROJECT_NAME_ALREADY_EXIST");
const identifierError = errorData?.identifier?.includes("PROJECT_IDENTIFIER_ALREADY_EXIST");
const nameSpecialCharError = errorData?.name?.includes("PROJECT_NAME_CANNOT_CONTAIN_SPECIAL_CHARACTERS");

if (nameError || identifierError) {
if (nameError || identifierError || nameSpecialCharError) {
if (nameError) {
setToast({
type: TOAST_TYPE.ERROR,
Expand All @@ -136,6 +137,14 @@ export const CreateProjectForm = observer(function CreateProjectForm(props: TCre
message: t("project_identifier_already_taken"),
});
}

if (nameSpecialCharError) {
setToast({
type: TOAST_TYPE.ERROR,
title: t("toast.error"),
message: t("project_name_cannot_contain_special_characters"),
});
}
Comment on lines 120 to +147
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The identifier input already has frontend-level protection via projectIdentifierSanitizer in packages/utils/src/project.ts, which strips special characters on every keystroke before the value is stored in the form. This is wired up in apps/web/core/components/project/create/common-attributes.tsx via handleIdentifierChange. Special characters physically cannot be typed into the identifier field, so PROJECT_IDENTIFIER_CANNOT_CONTAIN_SPECIAL_CHARACTERS cannot be triggered from the project creation form.

However, since the backend API does handle this case in ProjectSerializer.validate_identifier(), I'm happy to add a defensive handler on the frontend as an extra safety layer if the maintainers feel it's necessary.

} else {
setToast({
type: TOAST_TYPE.ERROR,
Expand Down