PaddlePaddle/PaddleOCR · critical · Error

${kind} model requires a non-empty ${MODEL_ENTRY_PATHS.model

Error message

${kind} model requires a non-empty ${MODEL_ENTRY_PATHS.model} resource.

What it means

Thrown by assertModelResourceSlot() when the "model" slot of loaded model resources is not a non-empty Uint8Array. The tar bundle must contain the model entry file (path from MODEL_ENTRY_PATHS.model) with at least one byte. It fires when the archive was extracted but the model entry is missing/empty - i.e. a wrong or corrupt bundle passed the download check but does not contain the expected ONNX/model file.

Source

Thrown at paddleocr-js/packages/core/src/resources/model-asset.ts:104

  if (assetEntries.length === 0) {
    throw new Error("Assets must define at least one asset.");
  }

  return Object.fromEntries(
    assetEntries.map(([assetName, asset]) => [assetName, normalizeModelAsset(assetName, asset)])
  );
}

// --- Model loading ---

export function getModelEntryPath(slot: string): string | null {
  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);
  }

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Verify the tar actually contains the model entry path (inspect with `tar -tf model.tar`) and re-package with the expected file layout
  2. Point assets at the official bundle URL for your model
  3. Clear any cached downloads and re-fetch; check the bundle size against the published size
  4. If building resources programmatically, ensure the model slot holds non-empty Uint8Array bytes

Example fix

# before (bundle missing model file)
tar -tf det.tar
# config/inference.yml

# after
# include the model weights file at the expected entry path
tar -tf det.tar
# inference.pdmodel / onnx model file present
# then: assets: { det: { url: "https://host/det.tar" } }
Defensive patterns

Strategy: validation

Validate before calling

function isValidModelSlot(v: unknown): boolean {
  return v instanceof Uint8Array && v.byteLength > 0;
}
// before assertModelResources: every resources.model passes isValidModelSlot

Type guard

function isNonEmptyBytes(v: unknown): v is Uint8Array {
  return v instanceof Uint8Array && v.byteLength > 0;
}

Prevention

When it happens

Trigger: Pointing assets at a tar that contains only a config (e.g. a params-only bundle), an HTML error page tarred by a bad CDN, or a truncated upload; manually constructing resources where the model bytes were never set.

Common situations: Self-hosting model bundles and packaging the wrong files; CDN returning a soft-200 error body; partial downloads saved to cache; custom pipeline code that populates resources itself.

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/97ec78812e653eac. Report an issue: GitHub.