fix(db): repair invalid environment labels before startup (#3130)

Normalize malformed Envs.labels values to JSON arrays during schema migration so ORM reads cannot abort HTTP worker initialization. Preserve valid label arrays and cover corrupt legacy rows. Fixes #3128.
This commit is contained in:
whyour authored and GitHub committed 2026-11-09 01:18:05 +08:00
1 parent 13e0ff55d4
commit 76b285c3db
2 files changed
+45 -1

No files matched your search

+11
View File
@@ -66,5 +66,16 @@ export async function migrateSchema(database: Sequelize): Promise<void> {
);
}
}
// Older databases can contain non-JSON values in Envs.labels. Sequelize
// parses this column on every environment read, including HTTP startup.
await database.query(
`UPDATE "Envs" SET "labels" = '[]'
WHERE CASE WHEN json_valid("labels")
THEN json_type("labels") <> 'array'
ELSE 1
END`,
{ transaction },
);
});
}