Skip to content
Source
Sign inSign up
TanStack/schemas

Fix BytePlus poll crash on a cached maker parse #744 (GitHub #743)

Mergedtombeckenhammerged 1 commit intomain fromfix/byteplus-maker-cache-shapemerged by tombeckenham View on GitHub

tombeckenhamcommented

Production symptom

The BytePlus models poll has thrown on every 15-minute run since 2026-11-21 05:46 UTC (05:46, 06:01, 06:16, 06:31, 06:46 seen), each with ingest_failed / models-poll / byteplus: Cannot read properties of undefined (reading 'dreamina-seedance-2-5-flash-261115'). #731 deployed at 05:20; the 05:30 poll succeeded (cold docs cache) and every warm poll since has failed. Stored rows are kept, but BytePlus has not updated since.

Root cause

It was not a Set/Map failing to survive JSON. Both cached shapes were plain JSON. The problem was that two loaders cached different shapes under one KV key:

  • byteplusServerTools (byteplus-tools.ts:75) caches { mcp, hash } at docs:v46:<BYTEPLUS_MODEL_LIST_URL>
  • byteplusModelMakers (#731, byteplus-pricing.ts:1598) cached { makers, named, hash } at the same key

Both run in the same poll (byteplus.ts:630-631). On a cold cache, both miss, both parse and both write, and the last write wins. On the next poll, one of them reads the other's entry. Here the maker lookup got { mcp, hash }, so list.makers was undefined and list.makers[rawId] (byteplus-pricing.ts:1615) threw on the first id it read. The reverse order would have thrown in the tools lookup (doc.mcp[rawId]).

Fix

  • The maker parse now caches under ${BYTEPLUS_MODEL_LIST_URL}#makers, the repo's existing convention for a second parse of a page (#serverless-chat, #native-thinking, Mistral's #makers).
  • DOCS_CACHE_VERSION v46 → v47, so every v46 entry, whichever shape it holds, is dropped on deploy.
  • The read is not made tolerant: a missing field after a cache hit still throws.

Guards

  • byteplus-tools.test.ts: the tools and maker loaders run against one fake KV, in both orders. On main this fails with the production error, word for word.
  • docs-cache-keys.test.ts (new): fails when two call sites under src/server/providers cache under the same key expression. It would have flagged #731. NVIDIA_SITEMAP_URL is allowlisted because both of its sites cache the same parseNvidiaInferSitemap output.
  • cachedDocs now returns a fresh load JSON round-tripped (JSON.parse(JSON.stringify(...))). A Map, Set or Date in a cached shape then breaks the first poll and every unit test, not only warm polls.

Other cached parsers checked

With the round-trip in cachedDocs, the full suite passes (263 files, 2694 tests), so no tested loader caches a value JSON does not keep. Checked by hand as well:

  • Mistral makers (adapters/mistral.ts, MISTRAL_MAKERS_KEY = ${MISTRAL_DEPRECATIONS_URL}#makers, Object.fromEntries + array): OK
  • Mistral pricing, overview #api-slugs, models index, web search, release-date page entries (mistral-pricing.ts): records and arrays, OK
  • Gemma card, deprecations, changelog aliases (gemini-bindings.ts): Object.fromEntries, OK
  • dashscope-cn compat #route, realtime #family, deep research #family (dashscope-cn.ts): own keys, OK
  • Kimi Code (kimi-code.ts), Vertex Claude (vertex-claude.ts, #models): OK
  • gemini-features.ts index, thinking and model pages; openai-model-docs.ts index, #search-v2, model pages; byteplus-tools.ts: OK (the BytePlus tools key was the collision fixed here)
  • Anthropic aliases (provider-aliases.ts): OK
  • OpenRouter canonical_slug (#736): read from the live listing, not a docs cache. Not affected.
  • Cross-file duplicate URL literals (Together supported-models, serverless models, reasoning and quickstarts; z.ai thinking; Cerebras spec; DeepSeek models): each is uncached on one side or already has its own #suffix. No collision.

Ceiling of the key test: it compares key expressions as written. Two different constants that hold the same URL, or a helper's url parameter, are not caught.

    1. ⚠️ No Changeset found

      Latest commit: 652287adbcf9d9516c4dbcf1bd1243c7ec87b4d6

      Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

      This PR includes no changesets

      When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

      Click here to learn what changesets are, and how to add one.

      Click here if you're a maintainer who wants to add a changeset to this PR

    2. Warning

      Review limit reached

      You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

      Next included review available in 22 minutes.

      Check out review usage here.

      View limit details

      Limit details: You’ve used the included review currently available.

      Learn how review limits work.

      Review configuration:

      Run configuration

      • Source mode: Auto
      • Repository: Unavailable
      • Branch: Unavailable
      • File: No configuration file from this repository applied
      • Commit: Unavailable
      • Layers: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 56cdbcaf-acee-41f8-bb83-08d64a0014d8
      Commits

      Reviewing files that changed from the base of the PR and between aaf0f8a0ef4cca06f20de7b7d74b150da2837caf and 652287adbcf9d9516c4dbcf1bd1243c7ec87b4d6.

      Files selected for processing: 4

      • src/server/providers/byteplus-pricing.ts
      • src/server/providers/byteplus-tools.test.ts
      • src/server/providers/docs-cache-keys.test.ts
      • src/server/providers/model-facts.ts
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      Share

    3. tombeckenham merged thisb431a9a

    4. tombeckenham closed this

Sign in to join this conversation.