[PR #4518] [CLOSED] Bug Fix: File Parsing Fails for URLs Without Explicit File Extensions #4660

Closed
opened 2026-02-22 18:36:17 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4518
Author: @Guru6163
Created: 10/8/2025
Status: Closed

Base: masterHead: bugfix/handle-urls-without-file-ext


📝 Commits (2)

  • c7c07ec Bug Fix: File Parsing Fails for URLs Without Explicit File Extensions
  • 14d1974 lint

📊 Changes

2 files changed (+50 additions, -4 deletions)

View changed files

📝 collector/processLink/index.js (+4 -2)
📝 collector/utils/downloadURIToFile/index.js (+46 -2)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

resolves #4513

Root Cause

The downloadURIToFile function was using path.basename(url) to determine filenames, which didn't account for HTTP Content-Type headers that indicate the actual file type.

Solution

Enhanced the file download logic to:

  • Extract Content-Type from HTTP response headers
  • Map Content-Type to appropriate file extension using existing ACCEPTED_MIMES configuration
  • Generate proper filenames with correct extensions

Changes

  • Added getExtensionFromContentType() function to map MIME types to extensions
  • Added generateSafeFilename() function for Content-Type aware filename generation
  • Modified download logic to use Content-Type headers for proper file extension assignment

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/4518 **Author:** [@Guru6163](https://github.com/Guru6163) **Created:** 10/8/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `bugfix/handle-urls-without-file-ext` --- ### 📝 Commits (2) - [`c7c07ec`](https://github.com/Mintplex-Labs/anything-llm/commit/c7c07ecfa84f3c27e9598fb657f7ee4637d39a0c) Bug Fix: File Parsing Fails for URLs Without Explicit File Extensions - [`14d1974`](https://github.com/Mintplex-Labs/anything-llm/commit/14d197406b57ebe0dd0cf2da358194cac5fb3079) lint ### 📊 Changes **2 files changed** (+50 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `collector/processLink/index.js` (+4 -2) 📝 `collector/utils/downloadURIToFile/index.js` (+46 -2) </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [ ] ✨ feat - [x] 🐛 fix - [ ] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Relevant Issues resolves #4513 ### Root Cause The `downloadURIToFile` function was using `path.basename(url)` to determine filenames, which didn't account for HTTP Content-Type headers that indicate the actual file type. ### Solution Enhanced the file download logic to: - Extract Content-Type from HTTP response headers - Map Content-Type to appropriate file extension using existing `ACCEPTED_MIMES` configuration - Generate proper filenames with correct extensions ### Changes - Added `getExtensionFromContentType()` function to map MIME types to extensions - Added `generateSafeFilename()` function for Content-Type aware filename generation - Modified download logic to use Content-Type headers for proper file extension assignment ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:36:17 -05:00
yindo closed this issue 2026-02-22 18:36:17 -05:00
yindo changed title from [PR #4518] Bug Fix: File Parsing Fails for URLs Without Explicit File Extensions to [PR #4518] [CLOSED] Bug Fix: File Parsing Fails for URLs Without Explicit File Extensions 2026-06-05 15:19:41 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4660