fix: add defensive checks for survey.endings in API and migration

- Add null check in app sync utils for recall info replacement
- Add null check in database migration for endings cleanup
This commit is contained in:
Cursor Agent
2026-02-05 08:52:28 +00:00
parent 2a4aa806db
commit e21328770d
2 changed files with 2 additions and 2 deletions

View File

@@ -38,7 +38,7 @@ export const replaceAttributeRecall = (survey: TSurvey, attributes: TAttributes)
}
});
}
surveyTemp.endings.forEach((ending) => {
(surveyTemp.endings ?? []).forEach((ending) => {
if (ending.type === "endScreen") {
languages.forEach((language) => {
if (ending.headline && ending.headline[language]?.includes("recall:")) {

View File

@@ -62,7 +62,7 @@ export const removeEmptyImageAndVideoUrlsFromElements: MigrationScript = {
delete cleanedWelcomeCard.videoUrl;
}
const cleanedEndings = survey.endings.map((ending) => {
const cleanedEndings = (survey.endings ?? []).map((ending) => {
const cleanedEnding = { ...ending };
if (cleanedEnding.imageUrl === "") {
delete cleanedEnding.imageUrl;