CodeSampleX

Sample

serialize-error 7.0.1: deserializeError

Verified sample for npm serialize-error 7.0.1: deserializeError. The contract ran on node 22 · linux debian/x64 · docker and passed.

sha256:7f2cdd9a3cdb14f1ea397cab46e7100165443c892969a2d019a49a135ee18903

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

Verification-run environments

Environment Contract Stages Run
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-04

Case

HOW
Goal
verify serialize-error.deserializeError in pkg:npm/serialize-error@7.0.1
Packages
Symbols
  • serialize-error.deserializeError
Created
2026-09-04T11:13:33Z

Contract

  1. deserializeError passes through existing Error instances unchanged
  2. deserializeError deserializes error object restoring name, message, stack, and code
  3. deserializeError preserves custom enumerable properties on error object
  4. deserializeError keeps name, message, and stack as non-enumerable properties
  5. deserializeError handles circular references in custom properties
  6. deserializeError ignores function properties on serialized object
  7. deserializeError wraps primitive string value into NonError instance
  8. deserializeError wraps primitive number and boolean into NonError instance
  9. deserializeError wraps null and undefined into NonError instance
  10. deserializeError wraps array into NonError instance

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify serialize-error.deserializeError in pkg:npm/serialize-error@7.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/serialize-error@7.0.1
Demonstrate these symbols/APIs:
  - serialize-error.deserializeError

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:71816cb67851b502adba12b13de4efd213889050319a2dd4811911c788ab405a","contract":["deserializeError passes through existing Error instances unchanged","deserializeError deserializes error object restoring name, message, stack, and code","deserializeError preserves custom enumerable properties on error object","deserializeError keeps name, message, and stack as non-enumerable properties","deserializeError handles circular references in custom properties","deserializeError ignores function properties on serialized object","deserializeError wraps primitive string value into NonError instance","deserializeError wraps primitive number and boolean into NonError instance","deserializeError wraps null and undefined into NonError instance","deserializeError wraps array into NonError instance"],"goal":"verify serialize-error.deserializeError in pkg:npm/serialize-error@7.0.1","kind":"HOW","packages":["pkg:npm/serialize-error@7.0.1"],"schemaVersion":1,"symbols":["serialize-error.deserializeError"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/serialize-error@7.0.1"],"schemaVersion":1,"subject":"pkg:npm/serialize-error@7.0.1","symbols":["serialize-error.deserializeError"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-serialize-error-deserialize-error",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-serialize-error-deserialize-error",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "serialize-error": "7.0.1"
      }
    },
    "node_modules/serialize-error": {
      "version": "7.0.1",
      "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz",
      "integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==",
      "license": "MIT",
      "dependencies": {
        "type-fest": "^0.13.1"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/type-fest": {
      "version": "0.13.1",
      "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz",
      "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==",
      "license": "(MIT OR CC0-1.0)",
      "engines": {
        "node": ">=10"
      }
    }
  }
}
package.json
{
  "name": "sample-serialize-error-deserialize-error",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "serialize-error": "7.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify serialize-error.deserializeError in pkg:npm/serialize-error@7.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/serialize-error@7.0.1"
  ],
  "symbols": [
    "serialize-error.deserializeError"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { deserializeError } from 'serialize-error';

// 1. deserializeError passes through existing Error instances unchanged
{
  const err = new TypeError('original error');
  const result = deserializeError(err);
  assert.equal(result, err);
  assert.equal(result instanceof TypeError, true);
}

// 2. deserializeError deserializes error object restoring name, message, stack, and code
{
  const serialized = {
    name: 'CustomError',
    message: 'failed operation',
    stack: 'CustomError: failed operation\n    at Object.<anonymous>',
    code: 'ERR_FAILED'
  };
  const result = deserializeError(serialized);
  assert.equal(result instanceof Error, true);
  assert.equal(result.name, 'CustomError');
  assert.equal(result.message, 'failed operation');
  assert.equal(result.stack, 'CustomError: failed operation\n    at Object.<anonymous>');
  assert.equal(result.code, 'ERR_FAILED');
}

// 3. deserializeError preserves custom enumerable properties on error object
{
  const serialized = {
    message: 'with details',
    status: 404,
    context: { userId: '123' }
  };
  const result = deserializeError(serialized);
  assert.equal(result.status, 404);
  assert.deepEqual(result.context, { userId: '123' });
}

// 4. deserializeError keeps name, message, and stack as non-enumerable properties
{
  const serialized = {
    name: 'MyError',
    message: 'secret message',
    stack: 'stack line',
    code: 'ERR_CODE',
    custom: 'visible'
  };
  const result = deserializeError(serialized);
  const keys = Object.keys(result);
  assert.equal(keys.includes('name'), false);
  assert.equal(keys.includes('message'), false);
  assert.equal(keys.includes('stack'), false);
  assert.equal(keys.includes('code'), true);
  assert.equal(keys.includes('custom'), true);
}

// 5. deserializeError handles circular references in custom properties
{
  const circular = { message: 'circular test', nested: {} };
  circular.nested.self = circular.nested;
  const result = deserializeError(circular);
  assert.equal(result.nested.self, '[Circular]');
}

// 6. deserializeError ignores function properties on serialized object
{
  const serialized = {
    message: 'fn test',
    helper: () => 'noop'
  };
  const result = deserializeError(serialized);
  assert.equal('helper' in result, false);
}

// 7. deserializeError wraps primitive string value into NonError instance
{
  const result = deserializeError('something bad');
  assert.equal(result instanceof Error, true);
  assert.equal(result.name, 'NonError');
  assert.equal(result.message, '"something bad"');
}

// 8. deserializeError wraps primitive number and boolean into NonError instance
{
  const numResult = deserializeError(404);
  assert.equal(numResult.name, 'NonError');
  assert.equal(numResult.message, '404');

  const boolResult = deserializeError(false);
  assert.equal(boolResult.name, 'NonError');
  assert.equal(boolResult.message, 'false');
}

// 9. deserializeError wraps null and undefined into NonError instance
{
  const nullResult = deserializeError(null);
  assert.equal(nullResult.name, 'NonError');
  assert.equal(nullResult.message, 'null');

  const undefResult = deserializeError(undefined);
  assert.equal(undefResult.name, 'NonError');
  assert.equal(undefResult.message, '');
}

// 10. deserializeError wraps array into NonError instance
{
  const arrResult = deserializeError(['error1', 'error2']);
  assert.equal(arrResult.name, 'NonError');
  assert.equal(arrResult.message, '["error1","error2"]');
}

Origin Seeder

anonymous