affaan-m/ECC · error · Error

Nasiko manifest layer size is outside the allowed range.

Error message

Nasiko manifest layer size is outside the allowed range.

What it means

validateManifest bounds the declared layer size: it must be a safe positive integer no larger than MAX_ARCHIVE_BYTES. The error is thrown when the size field is missing, non-numeric, zero/negative, or exceeds the configured limit — protecting the installer from absurd or corrupted size declarations before it allocates or downloads anything.

Solutions

  1. Log manifest.layers[0] and confirm the size key exists and is a number.
  2. Check the declared size against MAX_ARCHIVE_BYTES and confirm you selected the correct small release artifact, not a full container image.
  3. Republish or re-export the manifest with a correct integer size field if you control the artifact.
  4. If size is legitimately larger than the limit, the library cannot install it — use a different distribution path.

Example fix

// before
validateManifest(manifestBytes);
// after
const layer = JSON.parse(manifestBytes.toString('utf8')).layers[0];
if (!Number.isSafeInteger(layer.size) || layer.size <= 0) {
  throw new Error(`manifest size invalid: ${JSON.stringify(layer.size)} — republish artifact`);
}
validateManifest(manifestBytes);
Defensive patterns

Strategy: validation

Validate before calling

const layer = JSON.parse(manifestBytes.toString('utf8')).layers[0];
if (!Number.isSafeInteger(layer.size) || layer.size <= 0 || layer.size > MAX_ARCHIVE_BYTES) throw new Error('layer.size out of allowed range');

Type guard

const hasValidSize = (l) => Number.isSafeInteger(l?.size) && l.size > 0;

Try / catch

try { installNasiko(opts); } catch (e) { if (e.message.includes('size is outside the allowed range')) console.error('declared size invalid or artifact too large'); throw e; }

Prevention

When it happens

Trigger: layers[0].size is undefined/NaN/string in the manifest, is 0 or negative, or declares a value above MAX_ARCHIVE_BYTES (e.g. pointing at a huge image instead of the compact Nasiko artifact).

Common situations: Hand-edited manifest with a missing size key, publisher tool that omits size on some layers, accidentally targeting a full OS image, or a corrupted manifest transfer.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/12e611117b1e6dd3. Report an issue: GitHub.

Appendix: source

Thrown at scripts/lib/nasiko-release.js:71

function assertDigest(bytes, expectedDigest, label) {
  if (!SHA256_PATTERN.test(expectedDigest)) throw new Error(`${label} has an invalid expected digest.`);
  const actual = digestBytes(bytes);
  if (actual !== expectedDigest) throw new Error(`${label} digest mismatch: expected ${expectedDigest}, got ${actual}.`);
}

function validateManifest(bytes) {
  let manifest;
  try { manifest = JSON.parse(bytes.toString('utf8')); } catch (_error) { throw new Error('Nasiko manifest is not valid JSON.'); }
  if (manifest.schemaVersion !== 2 || !Array.isArray(manifest.layers) || manifest.layers.length !== 1) {
    throw new Error('Nasiko manifest must contain exactly one OCI layer.');
  }
  const layer = manifest.layers[0];
  if (layer.mediaType !== 'application/gzip' || !SHA256_PATTERN.test(layer.digest)) {
    throw new Error('Nasiko manifest layer is not a qualified gzip artifact.');
  }
  if (!Number.isSafeInteger(layer.size) || layer.size <= 0 || layer.size > MAX_ARCHIVE_BYTES) {
    throw new Error('Nasiko manifest layer size is outside the allowed range.');
  }
  return { digest: layer.digest, size: layer.size };
}

function readTarString(block, offset, length) {
  return block.subarray(offset, offset + length).toString('utf8').replace(/\0.*$/, '');
}

function readTarOctal(block, offset, length) {
  const field = block.subarray(offset, offset + length).toString('ascii');
  const match = /^ *([0-7]+)[ \0]*$/.exec(field);
  if (!match) throw new Error('Unsafe Nasiko archive: invalid tar size field.');
  const size = Number.parseInt(match[1], 8);
  if (!Number.isSafeInteger(size) || size < 0) {
    throw new Error('Unsafe Nasiko archive: invalid tar size field.');
  }
  return size;
}

View on GitHub (pinned to 8321021c54)