{"slug": "my-job-filters-fail-open-a-renamed-json-field-would-turn-them-all-off", "title": "My Job Filters Fail Open. A Renamed JSON Field Would Turn Them All Off.", "summary": "A developer who runs Upwork Scout, a SaaS that emails freelancers matching Upwork job alerts, found by reading their own code that a renamed JSON field from the third-party Apify actor they depend on would silently disable every client-side filter. Because the parser tolerates missing fields and the matcher only rejects on positive evidence, a change like data.buyer becoming data.client would make all client filters pass without any error, flooding users with jobs they never asked for.", "body_md": "Upwork Scout is a small SaaS I run that emails freelancers new Upwork jobs matching their filters: categories, keywords, budget, client country, payment verified, minimum client spend, and an optional AI fit score on top. The jobs come from an Apify actor I do not own. I send it a boolean search, it sends back a JSON array, and I turn each item into a job document.\n\nThis week I reread the two files that sit on either side of that boundary: the parser that reads the actor's JSON, and the matcher that decides whether a job reaches your inbox. Each one is reasonable on its own. Together they make a promise I never meant to make: if the actor renames a field, the filters for that field quietly turn off, and nobody gets an error.\n\nI have not seen this happen in production. I found it by reading the code. Here is how it fits together.\n\nThe actor's output shape is not mine, so I wrote the parser to be tolerant. Every field is read through a small helper that tries a list of paths and returns the first one that has a value:\n\n``` js\nconst pick = (o: any, paths: string[]): any => {\n  for (const p of paths) {\n    const v = p.split(\".\").reduce((a, k) => (a == null ? a : a[k]), o);\n    if (v !== undefined && v !== null && v !== \"\") return v;\n  }\n  return null;\n};\n```\n\nThe posted date alone has nine candidate paths, from `data.opening.publishTime` down to `createdOn`, because over time I have seen the same data in different places. The client block is read from `data.buyer.*`, and every value goes through `numOrNull`, `strOrNull` or `boolOrNull`:\n\n``` js\nconst client: JobClient = {\n  country: strOrNull(pick(r, [\"data.buyer.location.country\"])),\n  paymentVerified: boolOrNull(pick(r, [\"data.buyerExtra.isPaymentMethodVerified\"])),\n  totalSpent: numOrNull(pick(r, [\"data.buyer.stats.totalCharges.amount\"])),\n  rating: numOrNull(pick(r, [\"data.buyer.stats.score\"])),\n  hires: numOrNull(pick(r, [\"data.buyer.stats.totalAssignments\"])),\n  // ...\n};\nconst hasClientData = Object.values(client).some((v) => v !== null);\n```\n\nIf none of those paths exist, the job still parses. It just has `client: null`. That was deliberate. I did not want one renamed field to throw away a perfectly good job.\n\nThere is one place the parser is strict. If the URL does not contain a job id that matches `~0?([0-9a-f]{12,})`, or there is no title, `parseItem` returns `null` and the item is dropped. No log, no counter.\n\nThe matcher has a policy written at the top of the file, and I still agree with it:\n\n```\n// Missing-data policy (consistent across all filters): when a job lacks the\n// data a filter needs (v1-era docs, or Upwork hid it), the job PASSES and the\n// UI/email flags the unknown instead. Filters only reject on positive evidence.\n```\n\nSo every client filter is guarded by a null check:\n\n```\nif (f.paymentVerifiedOnly && c?.paymentVerified === false) return false;\nif (f.minClientSpend != null && c?.totalSpent != null && c.totalSpent < f.minClientSpend) return false;\nif (f.clientCountries.length && c?.country && !matchCountry(c.country, f.clientCountries)) return false;\n```\n\nThe reasoning: Upwork genuinely hides some client data, and old job documents from v1 do not have these fields at all. If \"payment verified only\" rejected every job where I could not see the flag, users would miss real jobs and blame the product. A false positive costs you a few seconds of reading. A false negative costs you a job you never knew existed. For a job alert tool, failing open is the right default for one missing field on one job.\n\nNow imagine the actor ships a new version where `data.buyer` becomes `data.client`. Nothing crashes. Here is what happens, step by step:\n\n`pick` finds nothing for every client path. `client` becomes `null` for every job.`c?.paymentVerified === false` is never true. `c?.totalSpent != null` is never true. `c?.country` is never truthy.\nA user who set \"United States only, payment verified, at least $10k spent\" starts receiving every job in their category. The emails look normal. The scan reports success. The only visible change is that the small \"Client:\" line under each job disappears, because the email template just skips it when there is no client data. Nobody files a bug about a line that is not there.\n\nThe same shape applies to dates. The freshness check in the scan route is:\n\n```\nif (j.postedAt && now - j.postedAt > JOB_MAX_AGE_H * 3600_000) continue;\n```\n\nIf the date paths all miss, `postedAt` is `null`, the condition is false, and the job counts as fresh no matter how old it is. Deduplication against stored jobs stops the same job being sent twice, but the first time an old job shows up, it gets alerted as new.\n\nAnd the strict case is the mirror image. If the URL format changes so the id regex stops matching, every item is dropped. But `billedItems` is just `items.length`, so the run still records the spend, reports `newJobs: 0`, and returns 200. I wrote about a cousin of this before, when [my public job pages went empty and my code could not tell me why](https://dev.to/nabeelbaghoor/my-live-job-pages-are-all-empty-and-my-code-cannot-tell-me-why-508b). Same lesson, different door: tolerant code is quiet code.\n\nThe bug is not \"fail open\" and it is not \"tolerant parsing\". Both are correct for a single job. What is missing is any check at the level of the whole batch.\n\nOne job with no client data is Upwork hiding something. A whole run where zero out of forty jobs have client data is a schema change. Those two situations look identical to code that only ever asks about one job at a time.\n\nSo the fix I am planning, and have not shipped yet, works at the batch level:\n\n```\n// planned, not in the repo yet\ntype ParseHealth = {\n  billed: number;      // raw items the actor returned\n  parsed: number;      // items that survived parseItem\n  withClient: number;  // parsed jobs with any client data\n  withDate: number;    // parsed jobs with a postedAt\n};\n\nfunction batchLooksBroken(h: ParseHealth): string | null {\n  if (h.billed >= 5 && h.parsed === 0) return \"every item dropped: id or title path changed?\";\n  if (h.parsed >= 10 && h.withClient === 0) return \"no client data on any job: buyer path changed?\";\n  if (h.parsed >= 10 && h.withDate === 0) return \"no dates on any job: date paths changed?\";\n  return null;\n}\n```\n\nThree things change once that exists:\n\n**The scan reports it.** Those four numbers go into the run's stats next to `billedItems` and `newJobs`, so the log line itself shows when parsing degrades, not just when fetching fails.\n\n**The run stops pretending.** If `batchLooksBroken` returns a reason, the route returns a 502. The GitHub Actions job that pings the scan only fails when the status is not 200, so this is the difference between a red run and a green one.\n\n**Client filters fail closed for that batch only.** If the batch has zero client data, a user with a client filter set should get nothing from that batch rather than everything. One missing field on one job still passes, exactly like today. A missing field on every job means the data source changed, and \"you got no alerts for an hour\" is a much better failure than \"you got forty alerts that ignore your filters\".\n\nThe parser has a comment that says `parseItem` is \"Exported for tests\". There are no tests. The only check in the repo is a smoke script that hits the live pages and API.\n\nThe cheapest useful test here is not clever. It is one real item from the actor, saved as a JSON file with personal details removed, and a test that asserts the parsed job has a non-null `client`, `postedAt`, `budget` and `skills`. When the actor changes, the first thing I do is pull a fresh item, drop it next to the old one, and see which assertions break. That turns \"the emails feel noisier lately\" into a diff.\n\nI already had the evidence for this. The header comment in the parser says the field paths were \"verified against a real dataset item\". I verified them once, by hand, and kept the conclusion instead of the item.\n\n`billed`, `parsed`, and \"parsed with the field I filter on\" are three numbers and they cost nothing.\nIf you are building anything on top of a scraper or a third-party API you do not own, check whether your \"unknown passes\" rule has a ceiling. Mine did not. If you want to see the product this lives in, it is [Upwork Scout](https://upwork-scout.com), and the matching pipeline behind it is in [an earlier post about running cheap filters before the LLM](https://dev.to/nabeelbaghoor/cheap-filters-first-llm-last-running-an-ai-matcher-inside-a-cron-job-702).\n\nHow do you handle this in your own pipelines: do your filters fail open, fail closed, or does it depend on how much of the batch is missing?", "url": "https://wpnews.pro/news/my-job-filters-fail-open-a-renamed-json-field-would-turn-them-all-off", "canonical_source": "https://dev.to/nabeelbaghoor/my-job-filters-fail-open-a-renamed-json-field-would-turn-them-all-off-59in", "published_at": "2026-11-23 21:35:51+00:00", "updated_at": "2026-11-23 21:43:19.510149+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["Upwork Scout", "Upwork", "Apify"], "also_reported_by": [], "takeaway": "A tolerant parser combined with a fail-open matcher means a single renamed upstream field silently disables filters with no error, so validate that expected fields exist and alert when they go missing.", "recommendation": {"advice": "Add schema checks and alerts for expected upstream fields so a renamed field surfaces as an error instead of silently turning off filters.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/my-job-filters-fail-open-a-renamed-json-field-would-turn-them-all-off", "markdown": "https://wpnews.pro/news/my-job-filters-fail-open-a-renamed-json-field-would-turn-them-all-off.md", "text": "https://wpnews.pro/news/my-job-filters-fail-open-a-renamed-json-field-would-turn-them-all-off.txt", "jsonld": "https://wpnews.pro/news/my-job-filters-fail-open-a-renamed-json-field-would-turn-them-all-off.jsonld"}}