FlowiseAI/Flowise · error · Error

Invalid JSON in Search Domain Filter: ${exception}

Error message

Invalid JSON in Search Domain Filter: ${exception}

What it means

ChatPerplexity parses searchDomainFilterRaw: if it is a string it is JSON.parse'd into obj.searchDomainFilter (an array of domains); any SyntaxError is re-thrown with this label. Object inputs bypass parsing. This field maps to Perplexity's search_domain_filter API parameter.

Source

Thrown at packages/components/nodes/chatmodels/ChatPerplexity/ChatPerplexity.ts:224

        if (temperature) obj.temperature = parseFloat(temperature)
        if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
        if (topP) obj.topP = parseFloat(topP)
        if (topK) obj.topK = parseInt(topK, 10)
        if (presencePenalty) obj.presencePenalty = parseFloat(presencePenalty)
        if (frequencyPenalty) obj.frequencyPenalty = parseFloat(frequencyPenalty)
        if (timeout) obj.timeout = parseInt(timeout, 10)
        if (returnImages) obj.returnImages = returnImages
        if (returnRelatedQuestions) obj.returnRelatedQuestions = returnRelatedQuestions
        if (searchRecencyFilter && searchRecencyFilter !== '') obj.searchRecencyFilter = searchRecencyFilter
        if (cache) obj.cache = cache

        if (searchDomainFilterRaw) {
            try {
                obj.searchDomainFilter =
                    typeof searchDomainFilterRaw === 'object' ? searchDomainFilterRaw : JSON.parse(searchDomainFilterRaw)
            } catch (exception) {
                throw new Error('Invalid JSON in Search Domain Filter: ' + exception)
            }
        }

        if (proxyUrl) {
            console.warn('Proxy configuration for ChatPerplexity might require adjustments to FlowiseChatPerplexity wrapper.')
        }

        const perplexityModel = new ChatPerplexity(nodeData.id, obj)
        return perplexityModel
    }
}

module.exports = { nodeClass: ChatPerplexity_ChatModels }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Provide a JSON array of domains: ["example.com","site.org"] — no trailing comma, double quotes.
  2. If you only want one domain, use ["example.com"] not a bare string.
  3. JSON-lint the value before saving; validate it is an array of strings.
  4. When constructing programmatically, pass a real array to skip parsing.

Example fix

// before
searchDomainFilterRaw = 'example.com, site.org' // not JSON -> throws [96]

// after
searchDomainFilterRaw = '["example.com", "site.org"]'
Defensive patterns

Strategy: validation

Validate before calling

function parseSearchDomainFilter(raw) {
  if (!raw) return undefined
  if (Array.isArray(raw)) return raw
  try {
    const parsed = JSON.parse(raw)
    if (!Array.isArray(parsed)) throw new Error('searchDomainFilter must be a JSON array of strings')
    return parsed
  } catch (e) {
    throw new Error(`Search Domain Filter must be a JSON array like ["a.com"]: ${e.message}`)
  }
}
obj.searchDomainFilter = parseSearchDomainFilter(searchDomainFilterRaw)

Type guard

function isDomainArray(v: unknown): v is string[] {
  return Array.isArray(v) && v.every(x => typeof x === 'string')
}

Try / catch

try {
  return await initChatPerplexity(nodeData, options)
} catch (e) {
  if (e.message.includes('Invalid JSON in Search Domain Filter')) {
    throw new Error('Set Search Domain Filter to a JSON array, e.g. ["example.com"].')
  }
  throw e
}

Prevention

When it happens

Trigger: The Search Domain Filter input holds a malformed JSON array — e.g. a comma-separated string 'a.com,b.com' instead of ["a.com","b.com"], or an array with unquoted/trailing-comma entries. Reached only when searchDomainFilterRaw is a truthy string.

Common situations: Users type a comma-separated list instead of a JSON array; paste domains with surrounding quotes mismatched; leave a trailing comma; copy from docs that mangle quotes; confuse the filter (an array) with a single domain string.

Understand the failure class

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/11634ea1890cdf5e. Report an issue: GitHub.