fix(restore): tolerate empty settings/feedback text and raise settings value cap
This commit is contained in:
+5
-2
@@ -10,6 +10,7 @@ const USER_SETTING_VALUE_MAX = {
|
||||
feedback_prompts: 320000,
|
||||
};
|
||||
const USER_SETTING_VALUE_MAX_DEFAULT = 320000;
|
||||
const SETTINGS_VALUE_MAX = 320000;
|
||||
const BACKUP_TABLES = [
|
||||
'groups', 'students', 'entries', 'project_files', 'branches', 'users', 'user_branches',
|
||||
'user_settings', 'user_notes',
|
||||
@@ -453,7 +454,9 @@ function normalizeRestoreData(data) {
|
||||
}));
|
||||
const settings = {};
|
||||
for (const [k, v] of Object.entries(data.settings || {})) {
|
||||
settings[reqStr(k, 100)] = reqStr(String(v), 15000);
|
||||
const value = String(v);
|
||||
if (value.length > SETTINGS_VALUE_MAX) throw new Error('Invalid string length');
|
||||
settings[reqStr(k, 100)] = value;
|
||||
}
|
||||
const audit_log = (data.audit_log || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
@@ -564,7 +567,7 @@ function normalizeRestoreData(data) {
|
||||
topic: optStr(r.topic),
|
||||
past_review: optStr(r.past_review),
|
||||
short_message_ids: Array.isArray(r.short_message_ids) ? r.short_message_ids.map(v => reqInt(v)) : [],
|
||||
text: optStr(r.text),
|
||||
text: optText(r.text, 100000),
|
||||
ai_status: optStr(r.ai_status) || 'none',
|
||||
ai_checked_at: optTs(r.ai_checked_at),
|
||||
ai_error: optStr(r.ai_error),
|
||||
|
||||
Reference in New Issue
Block a user