chatboxai/chatbox · error · Error

Querit search failed with status ${response.status}

Error message

Querit search failed with status ${response.status}

What it means

Thrown by searchNativeQuerit (src/shared/services/native-web-search.ts:203) when POST https://api.querit.ai/v1/search returns a non-2xx status. The request sends Authorization: Bearer <apiKey> and { query, count, filters? }. Note the asymmetry: an HTTP 200 carrying a business error_code !== 200 does NOT throw (it logs and returns []); only transport-level failures (non-ok) throw here. So this error specifically means the HTTP layer rejected the request, most often an auth/key problem.

Source

Thrown at src/shared/services/native-web-search.ts:203

  const body: { query: string; count: number; filters?: { timeRange: { date: string } } } = {
    query,
    count: options.maxResults ?? 5,
  }
  if (timeRange) {
    body.filters = { timeRange: { date: timeRange } }
  }

  const response = await fetchFn(QUERIT_SEARCH_URL, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${options.apiKey ?? ''}`,
    },
    body: JSON.stringify(body),
    signal: options.signal,
  })
  if (!response.ok) {
    throw new Error(`Querit search failed with status ${response.status}`)
  }
  const payload = (await response.json()) as {
    error_code?: number
    error?: unknown
    results?: { result?: Array<{ title: string; url: string; snippet: string }> }
  }
  if (payload.error_code !== 200) {
    // Keep the renderer's diagnostic: an HTTP 200 with a business error_code
    // (e.g. invalid/expired key) otherwise yields zero results with no trace.
    console.error('Querit search API error:', payload.error_code, payload.error)
    return []
  }
  if (!payload.results?.result || !Array.isArray(payload.results.result)) {
    return []
  }
  return payload.results.result.map((result) => ({
    title: result.title,
    link: result.url,

View on GitHub (pinned to 81571269ad)

Solutions

  1. Verify a non-empty, valid Querit API key is configured (options.apiKey) and that the user's plan/quota is active.
  2. Check options.signal is not already aborted before the call (an abort can surface as a failed fetch).
  3. Treat 429/5xx as transient: catch and degrade to 'no results' or retry with backoff rather than crashing the chat flow.
  4. Confirm reachability of https://api.querit.ai/v1/search from the runtime (mobile shell network, emulator, proxy).
  5. If you need the business-level error detail, note this throw only carries the HTTP status; enable the existing console.error path for error_code diagnostics on 200 responses.

Example fix

// before
const items = await searchNativeWeb(query, { provider: 'querit', apiKey })

// after
let items: NativeWebSearchResultItem[] = []
try {
  items = await searchNativeWeb(query, { provider: 'querit', apiKey })
} catch (e) {
  console.warn('querit search unavailable', e)
}
Defensive patterns

Strategy: validation

Validate before calling

// Use the shared config guard before invoking Querit
if (!hasNativeWebSearchConfiguration({ provider: 'querit', apiKey }, licenseKey)) {
  return [] // no valid key -> skip the failing call entirely
}

Try / catch

// Distinguish auth/quota from transient and degrade gracefully
try {
  return await searchNativeWeb(query, { provider: 'querit', apiKey, signal })
} catch (e) {
  const msg = (e as Error).message
  if (msg.includes('401') || msg.includes('403')) notifyInvalidKey()
  return []
}

Prevention

When it happens

Trigger: Querit POST returns response.ok === false, e.g. 401/403 for an empty/invalid/expired apiKey, 429 for quota/rate limit, 5xx for Querit outage, or a network/TLS failure surfaced as a non-ok response. An empty options.apiKey produces `Bearer ` and typically yields 401.

Common situations: User selected the Querit provider but never entered an API key; the key expired or hit its quota; options.apiKey is whitespace (sent verbatim as the bearer token); Querit API changed its URL or auth scheme; corporate firewall/proxy returns a blocking status page.

Related errors


AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12). Data as JSON: /api/errors/4af12c3add06e37a. Report an issue: GitHub.