Skip to content

fix: coerce env values to string before .includes() check in updateENV#5310

Closed
xandr0s wants to merge 1 commit intoMintplex-Labs:masterfrom
xandr0s:fix/update-env-type-coercion
Closed

fix: coerce env values to string before .includes() check in updateENV#5310
xandr0s wants to merge 1 commit intoMintplex-Labs:masterfrom
xandr0s:fix/update-env-type-coercion

Conversation

@xandr0s
Copy link
Copy Markdown

@xandr0s xandr0s commented Mar 31, 2026

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

POST /api/v1/system/update-env crashes with 500 when numeric values
are passed (e.g. GenericOpenAiEmbeddingMaxConcurrentChunks: 1).
Number type has no .includes() method — wrapping with String() fixes it.
@timothycarambat
Copy link
Copy Markdown
Member

You shouldn't be using the frontend API directly outside the UI because of things like this - what is the use case you are working for where you need to manipulate the update-env directly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants