Add sanity check of document length after image conversion, before ydoc conversion

This commit is contained in:
Tom Moor
2024-02-11 11:51:15 -05:00
parent de34f33058
commit 8da07fc118

View File

@@ -77,6 +77,13 @@ async function documentImporter({
transaction transaction
); );
// Sanity check text cannot possibly be longer than state so if it is, we can short-circuit here
if (text.length > DocumentValidation.maxStateLength) {
throw InvalidRequestError(
`The document "${title}" is too large to import, please reduce the length and try again`
);
}
// It's better to truncate particularly long titles than fail the import // It's better to truncate particularly long titles than fail the import
title = truncate(title, { length: DocumentValidation.maxTitleLength }); title = truncate(title, { length: DocumentValidation.maxTitleLength });