PaddlePaddle/PaddleOCR · error · Error
Unsupported model resource slot "${slot}".
Error message
Unsupported model resource slot "${slot}". What it means
Thrown by assertModelResourceSlot() when a resource key other than "model" or "config" appears in the resources record. The loader only understands these two slots (mapped to MODEL_ENTRY_PATHS entries); any extra key means the resource map was constructed from a bundle or code with unexpected entries, and it is rejected rather than ignored to surface packaging bugs.
Source
Thrown at paddleocr-js/packages/core/src/resources/model-asset.ts:116
return MODEL_ENTRY_PATHS[slot] || null;
}
export function assertModelResourceSlot(kind: string, slot: string, value: unknown): void {
if (slot === "model") {
if (!(value instanceof Uint8Array) || value.byteLength === 0) {
throw new Error(`${kind} model requires a non-empty ${MODEL_ENTRY_PATHS.model} resource.`);
}
return;
}
if (slot === "config") {
if (typeof value !== "string" || value.trim().length === 0) {
throw new Error(`${kind} model requires a non-empty ${MODEL_ENTRY_PATHS.config} resource.`);
}
return;
}
throw new Error(`Unsupported model resource slot "${slot}".`);
}
export function assertModelResources(kind: string, resources: Record<string, unknown>): void {
for (const [slot, value] of Object.entries(resources)) {
assertModelResourceSlot(kind, slot, value);
}
}
// --- Model loading (fetch + tar extraction) ---
import { extractTarEntries, pickTarEntry } from "./tar";
export async function loadModelAsset(
asset: ModelAsset,
fetchImpl: typeof fetch = fetch
): Promise<ModelLoadResult> {
const response = await fetchImpl(asset.url);
if (!response.ok) {View on GitHub (pinned to 2661c7c0ef)
Solutions
- Pass only the two recognized slots: { model: Uint8Array, config: string }
- Filter extracted tar entries down to MODEL_ENTRY_PATHS.model and .config before validation
- Update packaging so auxiliary files are not fed into assertModelResources
Example fix
# before (python/js pseudo)
resources = {e.name: e.data for e in tar_entries} # includes extra slots -> throws
# after
resources = {
"model": pick(tar_entries, "inference.pdmodel"),
"config": text_of(pick(tar_entries, "inference.yml")),
} Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED_SLOTS = new Set(["model", "config"]);
function onlyAllowedSlots(resources: Record<string, unknown>): boolean {
return Object.keys(resources).every(k => ALLOWED_SLOTS.has(k));
} Type guard
type ModelSlots = { model: Uint8Array; config: string };
function isModelSlots(v: Record<string, unknown>): v is ModelSlots {
const keys = Object.keys(v);
return keys.every(k => k === "model" || k === "config") &&
v.model instanceof Uint8Array && typeof v.config === "string";
} Prevention
- Map only MODEL_ENTRY_PATHS entries into the resources record
- Do not forward every tar entry as a resource slot
When it happens
Trigger: Populating resources with extra keys such as { model, config, vocab } or { model, config, metadata: ... }; looping over tar entries and passing all of them as resources instead of only the two recognized slots.
Common situations: Custom loaders that extract every tar entry into the resources map; bundles that add auxiliary files and consumer code copying them wholesale.
Related errors
- ${kind} model requires a non-empty ${MODEL_ENTRY_PATHS.model
- Entry "${targetName}" was not found in the tar archive.
- ${kind} model requires a non-empty ${MODEL_ENTRY_PATHS.confi
- Unsupported OCR model: {model}
- Unsupported document parsing model: {model}
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/6f4852b2c3f3111a.
Report an issue: GitHub.