Skip to content

Commit

Permalink
bugfix: Add nil check in escapeAllStrings to prevent TypeError when u…
Browse files Browse the repository at this point in the history
…psert vectors (#3789)
  • Loading branch information
nguyenhung10012003 authored Jan 2, 2025
1 parent 9cceba2 commit b34a823
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/components/nodes/vectorstores/Redis/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isNil } from 'lodash'

/*
* Escapes all '-' characters.
* Redis Search considers '-' as a negative operator, hence we need
Expand All @@ -8,6 +10,10 @@ export const escapeSpecialChars = (str: string) => {
}

export const escapeAllStrings = (obj: object) => {
if (isNil(obj)) {
// return if obj is null or undefined to avoid "TypeError: Cannot convert undefined or null to object"
return
}
Object.keys(obj).forEach((key: string) => {
// @ts-ignore
let item = obj[key]
Expand Down

0 comments on commit b34a823

Please sign in to comment.