Skip to content

fix(tracking): accept the new string-array Perplexity search_model_queries shape - #525

Merged
gkhngyk merged 1 commit into
mainfrom
fix/perplexity-fanout-string-shape
Jul 23, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/perplexity-fanout-string-shape

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Cloro's 2026-07-23 update changed the Perplexity search_model_queries field from [{ query, engine, limit }] objects to a plain string[] (matching how other providers expose fan-out). Our normalizer only handled the object shape — typeof q?.query === 'string' is false for a string entry — so every entry was silently filtered out and Perplexity results have been stored with an empty fan-out since the change shipped.

Verified against production data and live API calls:

  • prompt_results (perplexity-web): ~99% of results had fan-out through Jul 22; 0 of 426 on Jul 23.
  • Two live Cloro PERPLEXITY tasks (Jul 24) both returned search_model_queries as an array of strings; the current normalizer kept 0 entries from each.

Fix: normalizeSearchQueries now accepts both entry shapes — plain strings (new) map to { query, source_platform }, and legacy { query, engine } objects keep their engine label — so historical replays and a potential upstream revert both keep working. Stored row shape is unchanged; engine was already optional downstream, it's just absent on new rows.

No backfill is possible for Jul 23 rows (we don't store the raw response), but the window is a single day.

Related issue

—

Type of change

  • fix — Bug fix
  • feat — New feature
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd server && yarn vitest run src/lib/cloro-scraper.test.js — 22 tests pass, including the new plain-string shape case.
  2. After deploy, check a fresh Perplexity result: prompt_results.search_queries should be non-empty again and the Query Fan-out card on the prompt detail page should populate for new runs.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from server/)
  • yarn typecheck passes (web unchanged)
  • yarn format:check passes (run from server/)
  • Changes are focused — one concern per PR

@gkhngyk
gkhngyk merged commit 21419be into main Jul 23, 2026
5 checks passed
@gkhngyk
gkhngyk deleted the fix/perplexity-fanout-string-shape branch July 24, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant