Validate library doc file types before sending to Ivanti API
Library documents from the knowledge base were not checked against the allowed file extensions before being sent to Ivanti. If a doc had an unsupported type (e.g. .msg, .eml), Ivanti would reject the entire workflow with a 400. Now validates library docs the same way as local uploads and returns a clear error naming the offending file. Allowed: .pdf, .png, .jpg, .jpeg, .gif, .doc, .docx, .xlsx, .csv, .txt, .zip
This commit is contained in:
@@ -260,6 +260,12 @@ function createIvantiFpWorkflowRouter() {
|
|||||||
const foundIds = new Set(libraryDocs.map(d => d.id));
|
const foundIds = new Set(libraryDocs.map(d => d.id));
|
||||||
const missingIds = libraryDocIds.filter(id => !foundIds.has(id));
|
const missingIds = libraryDocIds.filter(id => !foundIds.has(id));
|
||||||
if (missingIds.length > 0) return res.status(400).json({ error: `Library document IDs not found: ${missingIds.join(', ')}` });
|
if (missingIds.length > 0) return res.status(400).json({ error: `Library document IDs not found: ${missingIds.join(', ')}` });
|
||||||
|
// Validate file types for library docs (same rules as local uploads)
|
||||||
|
const unsupportedDocs = libraryDocs.filter(d => !isAllowedFileExtension(d.name));
|
||||||
|
if (unsupportedDocs.length > 0) {
|
||||||
|
const names = unsupportedDocs.map(d => d.name).join(', ');
|
||||||
|
return res.status(400).json({ error: `Library document file type not supported by Ivanti: ${names}. Allowed: ${[...ALLOWED_EXTENSIONS].join(', ')}` });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const libraryFormFiles = [];
|
const libraryFormFiles = [];
|
||||||
@@ -821,6 +827,12 @@ function createIvantiFpWorkflowRouter() {
|
|||||||
const foundIds = new Set(libraryDocs.map(d => d.id));
|
const foundIds = new Set(libraryDocs.map(d => d.id));
|
||||||
const missingIds = libraryDocIds.filter(id => !foundIds.has(id));
|
const missingIds = libraryDocIds.filter(id => !foundIds.has(id));
|
||||||
if (missingIds.length > 0) return res.status(400).json({ error: `Library document IDs not found: ${missingIds.join(', ')}` });
|
if (missingIds.length > 0) return res.status(400).json({ error: `Library document IDs not found: ${missingIds.join(', ')}` });
|
||||||
|
// Validate file types for library docs
|
||||||
|
const unsupportedDocs = libraryDocs.filter(d => !isAllowedFileExtension(d.name));
|
||||||
|
if (unsupportedDocs.length > 0) {
|
||||||
|
const names = unsupportedDocs.map(d => d.name).join(', ');
|
||||||
|
return res.status(400).json({ error: `Library document file type not supported by Ivanti: ${names}. Allowed: ${[...ALLOWED_EXTENSIONS].join(', ')}` });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiKey = process.env.IVANTI_API_KEY;
|
const apiKey = process.env.IVANTI_API_KEY;
|
||||||
|
|||||||
Reference in New Issue
Block a user