From f6ed67b72320c18ad81ff878f3cad6cd2f376dad Mon Sep 17 00:00:00 2001 From: John Yeo Date: Sat, 22 Nov 2025 13:29:47 +0000 Subject: [PATCH] fix: update / create feature with empty ID / name --- server/src/utils/constants.ts | 1 + server/tests/_temp/temp1.test.ts | 7 +++++++ shared/api/features/featureV1OpModels.ts | 8 ++++++-- .../products/features/components/UpdateFeatureSheet.tsx | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/server/src/utils/constants.ts b/server/src/utils/constants.ts index 9d0e37a11..628c176d6 100644 --- a/server/src/utils/constants.ts +++ b/server/src/utils/constants.ts @@ -12,6 +12,7 @@ export const ADMIN_USER_IDs = [ "user_2tMgAiPsQzX8JTHjZZh9m0VdvUv", // a "user_2sB3tBXsnVVLlTKliQIqvvM2xfB", // j "ZsDswIXyOGMP9y1V1At4dAZNaiggClSs", // t + "NqNuL3MtS7MR2WYoqx2b28iY9vmfAs8h", // c ]; // process.env.ENV === "production" || process.env.NODE_ENV === "production" // ? [ diff --git a/server/tests/_temp/temp1.test.ts b/server/tests/_temp/temp1.test.ts index 6d6dc8f04..8e983ad0d 100644 --- a/server/tests/_temp/temp1.test.ts +++ b/server/tests/_temp/temp1.test.ts @@ -71,5 +71,12 @@ describe(`${chalk.yellowBright("temp: Testing add ons")}`, () => { customer_id: customerId, product_id: oneOff.id, }); + await autumn.attach({ + customer_id: customerId, + product_id: oneOff.id, + }); + + const customer = await autumn.customers.get(customerId); + console.log("Customer:", customer); }); }); diff --git a/shared/api/features/featureV1OpModels.ts b/shared/api/features/featureV1OpModels.ts index 6eed3a1c8..dd6389ac3 100644 --- a/shared/api/features/featureV1OpModels.ts +++ b/shared/api/features/featureV1OpModels.ts @@ -19,8 +19,12 @@ const featureDescriptions = { // Create Feature Params export const CreateFeatureV1ParamsSchema = z .object({ - id: z.string().meta({ description: featureDescriptions.id }), - name: z.string().nullish().meta({ description: featureDescriptions.name }), + id: z.string().nonempty().meta({ description: featureDescriptions.id }), + name: z + .string() + .nonempty() + .nullish() + .meta({ description: featureDescriptions.name }), type: z.enum(FeatureType).meta({ description: featureDescriptions.type }), consumable: z.boolean().optional(), diff --git a/vite/src/views/products/features/components/UpdateFeatureSheet.tsx b/vite/src/views/products/features/components/UpdateFeatureSheet.tsx index b335045b9..0baa1f65c 100644 --- a/vite/src/views/products/features/components/UpdateFeatureSheet.tsx +++ b/vite/src/views/products/features/components/UpdateFeatureSheet.tsx @@ -53,8 +53,8 @@ function UpdateFeatureSheet({ try { await FeatureService.updateFeature(axiosInstance, selectedFeature.id, { ...feature, - id: feature.id, - name: feature.name, + id: feature.id || undefined, + name: feature.name || undefined, type: feature.type, consumable: feature.config?.usage_type === FeatureUsageType.Single, event_names: feature.event_names,