[GH-ISSUE #2835] [Issue]: Curated sidecar GGUF download fails because approximate sizeBytes is validated as an exact byte count #1435

Closed
opened 2026-10-21 05:34:01 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @JM1k1 on GitHub (Jun 23, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2835

Curated sidecar GGUF download fails because rounded sizeBytes is used for exact validation

Summary

When downloading the curated sidecar model gemma-4-E2B-it-Q8_0.gguf, Marinara-Engine rejects the downloaded file at the final size validation step:

Downloaded file size mismatch: expected 5400000000 bytes, received 5048350848 bytes.

I may be missing some project-specific context, and I have not audited the entire codebase. However, from the sidecar-related files I checked, it looks like the curated model metadata stores approximate / rounded file sizes, while the download path later treats that same value as an exact byte count.

Expected behavior

The curated Q8 sidecar model should download successfully, pass validation, be saved as the active local model (for agents), and successfully process a local test message.

Actual behavior

The download completes with 5048350848 bytes received, but Marinara-Engine expects 5400000000 bytes and rejects the file with a size mismatch error.

This happened for me both when running from source and when using the launcher. I also tried both Node.js v26.3.1 and Node.js v24 LTS, and the behavior did not change.

Steps to reproduce

  1. Install or run Marinara Engine on Windows.
  2. Open the sidecar / local model setup.
  3. Select the curated Q8 sidecar model:
    • gemma-4-E2B-it-Q8_0.gguf
  4. Start the model download.
  5. Wait for the download to finish.

After the download finishes, the model is rejected with:

Downloaded file size mismatch: expected 5400000000 bytes, received 5048350848 bytes.

Environment

  • Marinara Engine version: 2.0.0
  • Install type: source and launcher
  • OS + version: Windows 11 Pro Build 26100
  • Browser or app shell: Chrome 149.0.7827.156 (x64)
  • Node.js tested:
    • v26.3.1
    • v24.17.0 LTS

What I found

At first I assumed sizeBytes might only be used as an approximate display value, because the type comment says:

/** Approximate file size in bytes. */
sizeBytes: number;

However, the curated GGUF presets currently contain rounded-looking values:

export const SIDECAR_MODELS: SidecarModelInfo[] = [
  {
    quantization: "q8_0",
    backend: "llama_cpp",
    label: "Gemma 4 E2B — Q8 (Best Quality)",
    filename: "gemma-4-E2B-it-Q8_0.gguf",
    sizeBytes: 5_400_000_000,
    ramBytes: 5_800_000_000,
    downloadUrl: "https://huggingface.co/unsloth/gemma-4-E2B-it-GGUF/resolve/main/gemma-4-E2B-it-Q8_0.gguf",
  },
  {
    quantization: "q4_k_m",
    backend: "llama_cpp",
    label: "Gemma 4 E2B — Q4_K_M (Smaller, Faster)",
    filename: "gemma-4-E2B-it-Q4_K_M.gguf",
    sizeBytes: 3_200_000_000,
    ramBytes: 3_600_000_000,
    downloadUrl: "https://huggingface.co/unsloth/gemma-4-E2B-it-GGUF/resolve/main/gemma-4-E2B-it-Q4_K_M.gguf",
  },
];

To verify the remote file size, I checked the file metadata exposed by the Hugging Face Hub API for the models used in the curated sidecar metadata.

The metadata returned by Hugging Face reports:

gemma-4-E2B-it-Q8_0.gguf: 5048350848 bytes
gemma-4-E2B-it-Q4_K_M.gguf: 3106731392 bytes

That exact value, 5048350848, is also the value Marinara-Engine reports as “received” in the error message.

So the current values appear to differ like this:

Q8_0:
  Hugging Face reported size:  5048350848 bytes
  sidecar.ts sizeBytes:        5400000000 bytes
Q4_K_M: 
  Hugging Face reported size:  3106731392 bytes
  sidecar.ts sizeBytes:        3200000000 bytes

I reproduced the failure with Q8_0. I did not separately reproduce the full Q4_K_M download failure, but the same kind of metadata mismatch appears to be present there too.

Why I think this causes the failure

In sidecar-model.service.ts, the curated model’s sizeBytes value is passed into the downloader as expectedBytes:

await this.downloadModelFile(
  {
    url: modelInfo.downloadUrl,
    relativePath,
    label: modelInfo.label,
    expectedBytes: modelInfo.sizeBytes,
  },
  onProgress,
);

The same sizeBytes value is also used when deciding whether an existing local model file is usable:

private isUsableModelFile(path: string, expectedSize: number | null | undefined): boolean {
  try {
    const actualSize = statSync(path).size;
    if (actualSize <= 0) {
      return false;
    }
    return typeof expectedSize === "number" && expectedSize > 0 ? actualSize === expectedSize : true;
  } catch {
    return false;
  }
}

Then, in sidecar-download.ts, expectedBytes is used as an exact byte count. After the temporary download finishes, the file size is compared directly against that value:

const expectedBytes =
  typeof options.expectedBytes === "number" && options.expectedBytes > 0 ? options.expectedBytes : total;

const canValidateSize = expectedBytes > 0 && (!contentEncoding || contentEncoding === "identity");

...

const writtenBytes = statSync(tempPath).size;

if (canValidateSize && writtenBytes !== expectedBytes) {
  throw new Error(`Downloaded file size mismatch: expected ${expectedBytes} bytes, received ${writtenBytes} bytes.`);
}

So, as I understand it, the flow is:

sidecar.ts
  sizeBytes: 5400000000

sidecar-model.service.ts
  passes that value as expectedBytes

sidecar-download.ts
  requires writtenBytes === expectedBytes

actual downloaded Q8_0 file
  writtenBytes = 5048350848

result
  5048350848 !== 5400000000
  download is rejected

This also explains why the error says:

expected 5400000000 bytes, received 5048350848 bytes

The expected value appears to come from the curated preset metadata, while the received value matches the remote file size reported by Hugging Face.

Local verification

As a local sanity check, I changed only the Q8 byte value in the sidecar metadata to match the remote file size reported by Hugging Face, rebuilt the app, and retried the same download. After that, the model downloaded successfully and the local model started:

Local Test Message Succeeded
249ms
Verification token: marinara-43e1fa98 • echoed by model
Usage: prompt 76, completion 30, total 106 • Timings: prompt 48.482ms / gen 194.938ms
Message Content
Line 1: TOKEN marinara-43e1fa98 Line 2: The local sidecar test has successfully completed.
Originally created by @JM1k1 on GitHub (Jun 23, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2835 # Curated sidecar GGUF download fails because rounded sizeBytes is used for exact validation ## Summary When downloading the curated sidecar model `gemma-4-E2B-it-Q8_0.gguf`, Marinara-Engine rejects the downloaded file at the final size validation step: ```text Downloaded file size mismatch: expected 5400000000 bytes, received 5048350848 bytes. ``` I may be missing some project-specific context, and I have not audited the entire codebase. However, from the sidecar-related files I checked, it looks like the curated model metadata stores approximate / rounded file sizes, while the download path later treats that same value as an exact byte count. ## Expected behavior The curated Q8 sidecar model should download successfully, pass validation, be saved as the active local model (for agents), and successfully process a local test message. ## Actual behavior The download completes with `5048350848` bytes received, but Marinara-Engine expects `5400000000` bytes and rejects the file with a size mismatch error. This happened for me both when running from source and when using the launcher. I also tried both Node.js v26.3.1 and Node.js v24 LTS, and the behavior did not change. ## Steps to reproduce 1. Install or run Marinara Engine on Windows. 2. Open the sidecar / local model setup. 3. Select the curated Q8 sidecar model: - `gemma-4-E2B-it-Q8_0.gguf` 4. Start the model download. 5. Wait for the download to finish. After the download finishes, the model is rejected with: ```text Downloaded file size mismatch: expected 5400000000 bytes, received 5048350848 bytes. ``` ## Environment - Marinara Engine version: 2.0.0 - Install type: source and launcher - OS + version: Windows 11 Pro Build 26100 - Browser or app shell: Chrome 149.0.7827.156 (x64) - Node.js tested: - v26.3.1 - v24.17.0 LTS ## What I found At first I assumed `sizeBytes` might only be used as an approximate display value, because the type comment says: ```ts /** Approximate file size in bytes. */ sizeBytes: number; ``` However, the curated GGUF presets currently contain rounded-looking values: ```ts export const SIDECAR_MODELS: SidecarModelInfo[] = [ { quantization: "q8_0", backend: "llama_cpp", label: "Gemma 4 E2B — Q8 (Best Quality)", filename: "gemma-4-E2B-it-Q8_0.gguf", sizeBytes: 5_400_000_000, ramBytes: 5_800_000_000, downloadUrl: "https://huggingface.co/unsloth/gemma-4-E2B-it-GGUF/resolve/main/gemma-4-E2B-it-Q8_0.gguf", }, { quantization: "q4_k_m", backend: "llama_cpp", label: "Gemma 4 E2B — Q4_K_M (Smaller, Faster)", filename: "gemma-4-E2B-it-Q4_K_M.gguf", sizeBytes: 3_200_000_000, ramBytes: 3_600_000_000, downloadUrl: "https://huggingface.co/unsloth/gemma-4-E2B-it-GGUF/resolve/main/gemma-4-E2B-it-Q4_K_M.gguf", }, ]; ``` To verify the remote file size, I checked the file metadata exposed by the Hugging Face Hub API for the models used in the curated sidecar metadata. The metadata returned by Hugging Face reports: gemma-4-E2B-it-Q8_0.gguf: 5048350848 bytes gemma-4-E2B-it-Q4_K_M.gguf: 3106731392 bytes That exact value, `5048350848`, is also the value Marinara-Engine reports as “received” in the error message. So the current values appear to differ like this: ```text Q8_0: Hugging Face reported size: 5048350848 bytes sidecar.ts sizeBytes: 5400000000 bytes Q4_K_M: Hugging Face reported size: 3106731392 bytes sidecar.ts sizeBytes: 3200000000 bytes ``` I reproduced the failure with Q8_0. I did not separately reproduce the full Q4_K_M download failure, but the same kind of metadata mismatch appears to be present there too. ## Why I think this causes the failure In `sidecar-model.service.ts`, the curated model’s `sizeBytes` value is passed into the downloader as `expectedBytes`: ```ts await this.downloadModelFile( { url: modelInfo.downloadUrl, relativePath, label: modelInfo.label, expectedBytes: modelInfo.sizeBytes, }, onProgress, ); ``` The same `sizeBytes` value is also used when deciding whether an existing local model file is usable: ```ts private isUsableModelFile(path: string, expectedSize: number | null | undefined): boolean { try { const actualSize = statSync(path).size; if (actualSize <= 0) { return false; } return typeof expectedSize === "number" && expectedSize > 0 ? actualSize === expectedSize : true; } catch { return false; } } ``` Then, in `sidecar-download.ts`, `expectedBytes` is used as an exact byte count. After the temporary download finishes, the file size is compared directly against that value: ```ts const expectedBytes = typeof options.expectedBytes === "number" && options.expectedBytes > 0 ? options.expectedBytes : total; const canValidateSize = expectedBytes > 0 && (!contentEncoding || contentEncoding === "identity"); ... const writtenBytes = statSync(tempPath).size; if (canValidateSize && writtenBytes !== expectedBytes) { throw new Error(`Downloaded file size mismatch: expected ${expectedBytes} bytes, received ${writtenBytes} bytes.`); } ``` So, as I understand it, the flow is: ```text sidecar.ts sizeBytes: 5400000000 sidecar-model.service.ts passes that value as expectedBytes sidecar-download.ts requires writtenBytes === expectedBytes actual downloaded Q8_0 file writtenBytes = 5048350848 result 5048350848 !== 5400000000 download is rejected ``` This also explains why the error says: ```text expected 5400000000 bytes, received 5048350848 bytes ``` The expected value appears to come from the curated preset metadata, while the received value matches the remote file size reported by Hugging Face. ## Local verification As a local sanity check, I changed only the Q8 byte value in the sidecar metadata to match the remote file size reported by Hugging Face, rebuilt the app, and retried the same download. After that, the model downloaded successfully and the local model started: ```code Local Test Message Succeeded 249ms Verification token: marinara-43e1fa98 • echoed by model Usage: prompt 76, completion 30, total 106 • Timings: prompt 48.482ms / gen 194.938ms Message Content Line 1: TOKEN marinara-43e1fa98 Line 2: The local sidecar test has successfully completed. ```
bsakaguchi 2026-10-21 05:34:01 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jun 23, 2026):

On it.

<!-- gh-comment-id:4780440423 --> @SpicyMarinara commented on GitHub (Jun 23, 2026): On it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1435
No description provided.