[PR #5310] [CLOSED] fix: coerce env values to string before .includes() check in updateENV #5402

Closed
opened 2026-06-05 15:21:14 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/5310
Author: @xandr0s
Created: 3/31/2026
Status: Closed

Base: masterHead: fix/update-env-type-coercion


📝 Commits (1)

  • 1406659 fix: coerce env values to string before .includes() check in updateENV

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 server/utils/helpers/updateENV.js (+1 -1)

📄 Description

Summary

  • Fix crash (500) in POST /api/v1/system/update-env when numeric values are passed
  • Root cause: .includes("******") called on Number type — Number has no .includes() method
  • Fix: wrap with String() before calling .includes()

Steps to reproduce

curl -X POST /api/v1/system/update-env   -d '{"GenericOpenAiEmbeddingMaxConcurrentChunks": 1}'
# => 500 Internal Server Error
# => TypeError: newENVs[key].includes is not a function

Change

- (key) => validKeys.includes(key) && !newENVs[key].includes("******")
+ (key) => validKeys.includes(key) && !String(newENVs[key]).includes("******")

Test plan

  • POST numeric value to /api/v1/system/update-env — no crash, value saved
  • POST string with ****** — still filtered correctly
  • POST normal string — saved as before

🔄 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/5310 **Author:** [@xandr0s](https://github.com/xandr0s) **Created:** 3/31/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/update-env-type-coercion` --- ### 📝 Commits (1) - [`1406659`](https://github.com/Mintplex-Labs/anything-llm/commit/1406659f5f8b88ebb3962ad784d1df5ea5ea403f) fix: coerce env values to string before .includes() check in updateENV ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `server/utils/helpers/updateENV.js` (+1 -1) </details> ### 📄 Description ## Summary - Fix crash (500) in `POST /api/v1/system/update-env` when numeric values are passed - Root cause: `.includes("******")` called on Number type — Number has no `.includes()` method - Fix: wrap with `String()` before calling `.includes()` ## Steps to reproduce ```bash curl -X POST /api/v1/system/update-env -d '{"GenericOpenAiEmbeddingMaxConcurrentChunks": 1}' # => 500 Internal Server Error # => TypeError: newENVs[key].includes is not a function ``` ## Change ```diff - (key) => validKeys.includes(key) && !newENVs[key].includes("******") + (key) => validKeys.includes(key) && !String(newENVs[key]).includes("******") ``` ## Test plan - [ ] POST numeric value to `/api/v1/system/update-env` — no crash, value saved - [ ] POST string with `******` — still filtered correctly - [ ] POST normal string — saved as before --- <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-06-05 15:21:14 -04:00
yindo closed this issue 2026-06-05 15:21:15 -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#5402