Compare commits

...

1 Commits

Author SHA1 Message Date
Cursor Agent
4e82dd1fa4 fix: handle undefined language properties in findLanguageCodesForDuplicateLabels
Fixes FORMBRICKS-E5

- Add safe null/undefined checks before calling .trim() on i18n string values
- Use type guard to filter out undefined or empty string values
- Prevents TypeError when language property doesn't exist in TI18nString object
- Aligns with the safer implementation already present in elements-validation.ts
2026-01-29 05:02:50 +00:00

View File

@@ -224,7 +224,10 @@ export const findLanguageCodesForDuplicateLabels = (
const duplicateLabels = new Set<string>();
for (const language of languagesToCheck) {
const labelTexts = labels.map((label) => label[language].trim()).filter(Boolean);
const labelTexts = labels
.map((label) => label[language])
.filter((text): text is string => typeof text === "string" && text.trim().length > 0)
.map((text) => text.trim());
const uniqueLabels = new Set(labelTexts);
if (uniqueLabels.size !== labelTexts.length) {