Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: adress pr feedback

IgorHorta55b7d241e013
diff --git a/backend/src/ee/routes/v1/sub-org-router.ts b/backend/src/ee/routes/v1/sub-org-router.ts
index ed13485d81..47cbc4ca16 100644
--- a/backend/src/ee/routes/v1/sub-org-router.ts
+++ b/backend/src/ee/routes/v1/sub-org-router.ts
@@ -57,7 +57,7 @@ export const registerSubOrgRouter = async (server: FastifyZodProvider) => {
event: {
type: EventType.CREATE_SUB_ORGANIZATION,
metadata: {
- name: req.body.name,
+ name: organization.name,
organizationId: organization.id
}
}
diff --git a/backend/src/ee/services/sub-org/sub-org-service.ts b/backend/src/ee/services/sub-org/sub-org-service.ts
index 9398ab6404..1ea4d9ed16 100644
--- a/backend/src/ee/services/sub-org/sub-org-service.ts
+++ b/backend/src/ee/services/sub-org/sub-org-service.ts
@@ -178,6 +178,10 @@ export const subOrgServiceFactory = ({
}
}
+ if (Object.keys(updateData).length === 0) {
+ return { organization: subOrg };
+ }
+
const organization = await orgDAL.updateById(subOrgId, updateData);
return {
diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/NewSubOrganizationForm.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/NewSubOrganizationForm.tsx
index 8a41800904..c61709c495 100644
--- a/frontend/src/layouts/OrganizationLayout/components/NavBar/NewSubOrganizationForm.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/NewSubOrganizationForm.tsx
@@ -18,7 +18,8 @@ type ContentProps = {
const AddOrgSchema = z.object({
name: GenericResourceNameSchema,
- slug: slugSchema()
+ // Optional: server auto-generates slug from name when not provided (backward compatibility)
+ slug: z.union([slugSchema(), z.literal("")]).optional()
});
type FormData = z.infer<typeof AddOrgSchema>;
@@ -52,7 +53,7 @@ export const NewSubOrganizationForm = ({ onClose, handleOrgSelection }: ContentP
const { organization } = await createSubOrg.mutateAsync({
name,
- slug
+ ...(slug?.trim() && { slug: slug.trim() })
});
createNotification({
@@ -90,7 +91,7 @@ export const NewSubOrganizationForm = ({ onClose, handleOrgSelection }: ContentP
render={({ field: { value, onChange }, fieldState: { error } }) => (
<FormControl
isError={Boolean(error)}
- helperText="Auto-generated from name. Must be slug-friendly."
+ helperText="Optional. Auto-generated from name when empty. Must be slug-friendly if set."
errorText={error?.message}
label="Slug"
>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgNameChangeSection/SubOrgNameChangeSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgNameChangeSection/SubOrgNameChangeSection.tsx
index af82b9fc51..e9730bea5a 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgNameChangeSection/SubOrgNameChangeSection.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgNameChangeSection/SubOrgNameChangeSection.tsx
@@ -1,3 +1,4 @@
+import { useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { useQueryClient } from "@tanstack/react-query";
@@ -30,13 +31,23 @@ export const SubOrgNameChangeSection = (): JSX.Element => {
const router = useRouter();
const queryClient = useQueryClient();
- const { handleSubmit, control } = useForm<FormData>({
+ const { handleSubmit, control, reset } = useForm<FormData>({
resolver: zodResolver(formSchema),
defaultValues: {
name: currentOrg?.name || "",
slug: currentOrg?.slug || ""
}
});
+
+ useEffect(() => {
+ if (currentOrg) {
+ reset({
+ name: currentOrg.name || "",
+ slug: currentOrg.slug || ""
+ });
+ }
+ }, [currentOrg?.id, currentOrg?.name, currentOrg?.slug, reset]);
+
const { mutateAsync, isPending } = useUpdateSubOrganization();
const onFormSubmit = async ({ name, slug }: FormData) => {