Skip to content

fix(node:buffer): reject primitive from inputs#2287

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-buffer-from-primitive-errors
May 28, 2026
Merged

fix(node:buffer): reject primitive from inputs#2287
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-buffer-from-primitive-errors

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Part of #793.

Summary

  • add a catchable TypeError [ERR_INVALID_ARG_TYPE] helper for invalid Buffer.from first arguments
  • reject primitive non-string Buffer.from inputs before raw pointer extraction
  • prevents nullish values from becoming empty Buffers and numeric primitives from being misread as heap pointers

Verification

  • DeepWiki: reference/deepwiki/nodejs-node-buffer-from-primitive-errors-2026-05-28.md (local only)
  • Baseline exact node-suite/buffer/from/primitive-errors: FAIL, report test-parity/reports/parity_report_20260528_114613.json; Perry printed empty buffers for nullish inputs and then segfaulted after the numeric primitive
  • Final exact node-suite/buffer/from/primitive-errors: PASS, report test-parity/reports/parity_report_20260528_115001.json
  • Full granular node-suite/buffer/from: 14 PASS / 2 parity FAIL, report test-parity/reports/parity_report_20260528_115045.json; target is green and the remaining reds are existing array-like/valueOf coercion gaps
  • Full granular node-suite/buffer: 104 PASS / 11 parity FAIL / 1 compile FAIL, report test-parity/reports/parity_report_20260528_115103.json; from/primitive-errors is green. Several sibling reds are covered by open PRs fix(node:buffer): reject negative allocation size #2274/fix(node:buffer): estimate base64 byte length #2276/fix(node:buffer): honor concat total length #2271/fix(node:buffer): expose default iterator #2280/fix(node:buffer): expose inspect surface #2282 or by separate coercion/range-error work.
  • cargo check -p perry-runtime -p perry-stdlib -p perry-codegen: PASS with existing warnings
  • cargo fmt --check: PASS
  • jq empty test-parity/known_failures.json: PASS
  • git diff --check: PASS

Non-goals

  • no Buffer.from object valueOf / Symbol.toPrimitive support
  • no array-like length coercion cleanup
  • no function/object invalid-input validation
  • no Buffer.alloc/write/fill coercion cleanup

@proggeramlug proggeramlug merged commit 0149371 into PerryTS:main May 28, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants