[PR #4630] [MERGED] Install patch-package in /collector and Apply Patch to Fix EPub Upload Bug #4699

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

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4630
Author: @angelplusultra
Created: 11/6/2025
Status: Merged
Merged: 11/19/2025
Merged by: @timothycarambat

Base: masterHead: 4582-epub-upload-bug


📝 Commits (2)

  • 279ea25 Install patch-package and postinstall-postinstall
  • aafa5fa Implement patch to ensure title is always a string in EPub class

📊 Changes

3 files changed (+279 additions, -11 deletions)

View changed files

📝 collector/package.json (+7 -4)
collector/patches/epub2+3.0.2.patch (+13 -0)
📝 collector/yarn.lock (+259 -7)

📄 Description

Pull Request Type

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

Relevant Issues

resolves #4582

What is in this change?

This PR

  1. Adds patch-package as a dependency inside /collector, an NPM package that allows for easy patching of code inside node_modules.
  2. Sets up patch-package as a yarn postinstall script inside package.json
  3. Applies a simple fix in the epub2 library to the EPub class to ensure title is a string before calling .trim()

Additional Information

Yarn has native lifecycle scripts, one of which is called postinstall which runs after packages are added, removed, etc. Read more here.

The postinstall script this PR adds calls patch-package, which looks at the patches directory and applies the git diffs it discovers inside there.

Example Execution Flow

  1. yarn install or yarn is executed
  2. Dependencies are installed
  3. postinstall script is executed which runs patch-package
  4. patch-package applies git diffs inside the relative patches directory to code in node_modules

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/4630 **Author:** [@angelplusultra](https://github.com/angelplusultra) **Created:** 11/6/2025 **Status:** ✅ Merged **Merged:** 11/19/2025 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `master` ← **Head:** `4582-epub-upload-bug` --- ### 📝 Commits (2) - [`279ea25`](https://github.com/Mintplex-Labs/anything-llm/commit/279ea25175d0e099eb84d3d718912be5bcf6d744) Install patch-package and postinstall-postinstall - [`aafa5fa`](https://github.com/Mintplex-Labs/anything-llm/commit/aafa5faa7e2e37bd70bd5f1e39fa421b22e29ef6) Implement patch to ensure title is always a string in EPub class ### 📊 Changes **3 files changed** (+279 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `collector/package.json` (+7 -4) ➕ `collector/patches/epub2+3.0.2.patch` (+13 -0) 📝 `collector/yarn.lock` (+259 -7) </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [x] ✨ feat - [x] 🐛 fix - [ ] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Relevant Issues <!-- Use "resolves #xxx" to auto resolve on merge. Otherwise, please use "connect #xxx" --> resolves #4582 ### What is in this change? <!-- Describe the changes in this PR that are impactful to the repo. --> This PR 1. Adds `patch-package` as a dependency inside `/collector`, an NPM package that allows for easy patching of code inside `node_modules`. 2. Sets up `patch-package` as a yarn postinstall script inside `package.json` 3. Applies a simple fix in the `epub2` library to the `EPub` class to ensure `title` is a string before calling `.trim()` ### Additional Information Yarn has native lifecycle scripts, one of which is called `postinstall` which runs ***after*** packages are added, removed, etc. Read more [here](https://yarnpkg.com/advanced/lifecycle-scripts#postinstall). The `postinstall` script this PR adds calls `patch-package`, which looks at the `patches` directory and applies the git diffs it discovers inside there. #### Example Execution Flow 1. `yarn install` or `yarn` is executed 2. Dependencies are installed 3. `postinstall` script is executed which runs `patch-package` 4. `patch-package` applies git diffs inside the relative `patches` directory to code in `node_modules` <!-- Add any other context about the Pull Request here that was not captured above. --> ### 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:21 -05:00
yindo closed this issue 2026-02-22 18:36:21 -05:00
yindo changed title from [PR #4630] Install `patch-package` in `/collector` and Apply Patch to Fix EPub Upload Bug to [PR #4630] [MERGED] Install `patch-package` in `/collector` and Apply Patch to Fix EPub Upload Bug 2026-06-05 15:19:54 -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#4699