fix(kit): don't crash prerender when a provider/task has no snippet#791
Merged
Conversation
`getInferenceSnippets` returns `[]` for a (provider, task) combo the bundled
`@huggingface/inference` has no helper for (it catches the `InferenceClientInputError`
internally). With no snippets, `selectedLanguage` is undefined, so
`clientsByLanguage[selectedLanguage]` is undefined and `{#if clients.length > 1}`
throws `Cannot read properties of undefined (reading 'length')`, which fails the
whole doc build (SvelteKit 500).
Default `clients` to `[]` so the component renders nothing for an unsupported
combo instead of taking down the build. This makes the prerender resilient to any
skew between the snippet versions used to generate docs vs. render them.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hanouticelina
added a commit
to huggingface/hub-docs
that referenced
this pull request
Jun 4, 2026
#791 merged; point both build workflows at the resulting doc-builder main commit (bcff59f) instead of the fix-branch head. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hanouticelina
added a commit
to huggingface/hub-docs
that referenced
this pull request
Jun 4, 2026
…render fix (#2531) * ci(inference-providers): bump doc-builder pin to InferenceSnippet prerender fix The inference-providers doc build crashes when a provider/task section has no snippet in the kit's `@huggingface/inference` (e.g. `together` + `automatic-speech-recognition`, supported by the generator's 4.13.18 but not the kit's pinned 4.13.15): the InferenceSnippet component dereferences `clients.length` on undefined → SvelteKit 500 → build fails on main and every PR. Bump the pinned doc-builder ref for both build workflows to the fix (huggingface/doc-builder#791), which defaults `clients` to `[]` so the prerender no longer crashes on an unsupported combo. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: repoint doc-builder pin to merged main (huggingface/doc-builder#791) #791 merged; point both build workflows at the resulting doc-builder main commit (bcff59f) instead of the fix-branch head. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: bump upload workflow doc-builder pin to bcff59f for consistency Keep all three inference-providers workflows on the same doc-builder main commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
InferenceSnippet.sveltecrashes the doc build when an<InferenceSnippet>is rendered for a(provider, task)combo that the kit's bundled@huggingface/inferencehas no helper for.snippets.getInferenceSnippets(...)catches theInferenceClientInputErrorinternally and returns[](it just logsFailed to get provider helper for …). With no snippets:That uncaught
TypeErrorbecomes a SvelteKit500during prerender and fails the entire build.This is reachable whenever the
@huggingface/inferenceversion used to generate the docs is ahead of the version the kit uses to render them. Real example:together+automatic-speech-recognitionwas added to inference in4.13.16; docs generated with4.13.18include that section, but the kit pins4.13.15, so the render throws and the build dies.Fix
Default
clientsto[]:The component now renders nothing for an unsupported combo instead of crashing the prerender — making the build resilient to any generator↔renderer version skew.
Verification
Reproduced the exact CI crash condition locally — docs containing the
together/ASR section, kit resolving the crashing@huggingface/inference@4.13.15:TypeError: Cannot read properties of undefined (reading 'length')→Error: 500 /providers/together→ build exit 1.providers/togetherprerenders successfully, noTypeError. TheFailed to get provider helper …line is still logged (harmless — the snippet just renders empty).Note
This is the minimal, structural safety net. Separately, bumping the kit's
@huggingface/inference(currently^4.13.15, lockfile-pinned to4.13.15) to a current release would make such sections render their snippet rather than degrade to empty — but that also pulls@huggingface/tasks^0.20.12→^0.21.x, so it's left as a separate maintainer decision.🤖 Generated with Claude Code