fix(parsers): fix md, pptx, html kb uploads#1209
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR fixes a bug where knowledge base uploads were rejecting MD, PPTX, and HTML files despite having backend parsers available for these formats. The solution centralizes file validation logic by creating a new validation module at /lib/uploads/validation.ts that maps file extensions to multiple MIME types to handle browser inconsistencies.
The changes extract hardcoded file type constants from two upload components (upload-modal.tsx and create-modal.tsx) and replace them with imports from the centralized validation module. The new validation system extends support to include 'ppt', 'pptx', 'html', and 'htm' extensions, with comprehensive MIME type mappings that account for various browser interpretations (e.g., MD files can be reported as 'text/markdown', 'text/x-markdown', 'text/plain', or 'application/markdown').
The validation module exports three key utilities: ACCEPTED_FILE_TYPES (flattened array of all supported MIME types), ACCEPTED_FILE_EXTENSIONS (array of file extensions with dot prefixes), and ACCEPT_ATTRIBUTE (combined string for HTML input accept attributes). This approach aligns with the codebase's pattern of using dedicated configuration files for component properties and ensures consistent file handling across all upload interfaces.
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it addresses a clear bug with a well-structured solution
- Score reflects solid architectural approach of centralizing validation logic and comprehensive MIME type handling, though manual testing only slightly reduces confidence
- Pay close attention to
/lib/uploads/validation.tsto ensure all supported file types have appropriate MIME type mappings
Context used:
Context - When defining properties for components, use a dedicated config file (.ts) for configuration and keep rendered components in their respective component files. (link)
3 files reviewed, no comments
* fix md, pptx, html * consolidate consts
* fix md, pptx, html * consolidate consts
* fix md, pptx, html * consolidate consts
Summary
fix md, pptx, html kb uploads. we added the parsers for them, but needed to add some additional logic to ensure we accept any of their formats in the UI uploads
Type of Change
Testing
Tested manually.
Checklist
Screenshots/Videos
Screen.Recording.2025-08-31.at.12.36.00.AM.mov