File attachments overhaul + message-files junction table#16
Open
1337hero wants to merge 14 commits into
Open
Conversation
- Drop unused PROVIDER_ATTACHMENT_CAPABILITIES (providerFactory is source of truth) - Drop FILE_CONFIG.ALLOWED_TYPES + validateFileType; validateFile now requires filename and gates purely on classifier - Remove orphan debug files at server/ root
- officeExtraction: decode XML entities (&, <, numeric/hex refs); shared extractTagText helper covers docx/xlsx/pptx - useChat: surface submit-failure errors via sendError merged into chat error banner; preserve files on failure - FileUpload: parallel uploads via Promise.allSettled instead of sequential await loop
- Drop dead code: formatErrorDetails, collectAttachmentIdsFromRequest, getMimeTypeFromExtension, asFileContentPart, lying error.response.body branch, unused warnings, double export - Replace forwardRef/useImperativeHandle file-input ceremony with native <label htmlFor>; FileUpload becomes useFileUploader hook + FilePreviewList - Split preflightAttachments into pure classifyForModel + small aggregator; drop hasImageDimensionIssue flag-leak - Return category from POST /api/files; FilePreviewList renders from server-classified category instead of re-deriving - Drop unused PROVIDER capability scaffold and unused ATTACHMENT_ACCEPT_* constants; ATTACHMENT_INPUT_ACCEPT now derives from FILE_CATEGORY_DEFINITIONS - Strip phase-numbered + name-restating JSDoc across attachment files - MessageAttachment query: staleTime/gcTime Infinity for immutable upload metadata
- useChat exposes discrete appendFiles/removeFile mutators instead of raw setInputFiles drilling - ChatInterface passes onFilesUploaded/onRemoveFile into InputArea (no setter exposed across boundary) - Split FileUpload.jsx into useFileUploader hook (frontend/src/hooks/useFileUploader.js) and FilePreviewList component (frontend/src/components/chat/FilePreviewList.jsx); each file is named after its single export
Add security-ports.test.js covering: - XSS/SQL injection/path traversal prevention - Data isolation between users (chats, files, metadata, content, delete) - Cross-user file attachment blocking (403) - Cascade delete: chat → messages gone - Input validation limits (100K message content, 200 char title, 50 char username, duplicate username, pagination cap) - Concurrent operations (parallel chat/file/message creation) - Dangerous file type rejection (SVG, .exe, zero-byte) Python test files (server/python_tests/) and manual rate-limit test script (server/test-rate-limit-bypass.sh) removed; all unique coverage is now in the Bun suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related bodies of work landed on this branch:
1. File attachments capability model (10 phases —
specs/file-attachments/)End-to-end overhaul of how uploads are validated, classified, sent to providers, and served back to the browser.
packages/shared/src/constants/files.js)server/src/lib/officeExtraction.js,.docx/.pptx/.xlsxfixtures + tests)server/src/lib/imageValidation.js)server/src/lib/providerErrors.js,providerFactory.js)ErrorBanner.jsx,errorHandler.js)server/src/lib/ssrf.js)FilePreviewList.jsx,useFileUploader.js,InputArea.jsx; replaces the oldFileUpload.jsx)2. Message↔Files junction table (
specs/message-files-junction-table.md)Replaces the JSON-array
messages.file_idscolumn with a proper relationalmessage_filesjunction table.003_message_files_junction.js— creates table, backfills from JSON, dropsfile_idscolumnON DELETE CASCADEonfiles(id)andmessages(id)— orphaned references can no longer accumulatefileIds: string[]) — frontend untouchedserver/src/test/db.message-files.test.jsOther improvements bundled in
server/src/lib/db.jsinto per-domain modules underserver/src/lib/db/(audit, chats, files, folders, memory, models, providers, settings, users)migrations/index.js)lib/errorHandler.js,providerErrors.js).oxlintrc.jsonaddedscripts/reset-admin-password.jsTest plan
bun run test— server suite passes (new files:db.message-files.test.js,files.test.js,imageValidation.test.js,officeExtraction.test.js)ErrorBanner