Skip to content

fix: build null validity predicates without dynamic code generation - #501

Open
ibgreen wants to merge 1 commit into
apache:mainfrom
ibgreen:codex/validity-without-dynamic-code
Open

ibgreen wants to merge 1 commit into
apache:mainfrom
ibgreen:codex/validity-without-dynamic-code

Conversation

@ibgreen

@ibgreen ibgreen commented Oct 13, 2026

Copy link
Copy Markdown

Goals

Allow Arrow builders to work in runtimes that prohibit eval and the Function constructor, without carrying a downstream bundle patch.

Closes #54.

Changes

  • Replace dynamically compiled switch statements with captured validity predicates.
  • Preserve the always-valid empty case and use direct comparisons for a single sentinel, including NaN.
  • Use a snapshot Set for multiple sentinels, retaining primitive type distinctions and positive/negative-zero matching. Membership operates on supplied values directly rather than serializing them; object/symbol sentinels therefore use identity.
  • Cover null, undefined, NaN, zeros, bigint, quoted/multiline strings, duplicates, input-list mutation and a blocked Function constructor.
  • Remove the generated-source serializer and update the helper documentation.

Verification

  • New predicate tests plus existing builder conformance: 447 passed.
  • Final predicate rerun: 12 passed; changed-file ESLint passed.
  • Source build type check: tsc --noEmit -p tsconfig/tsconfig.esnext.esm.json passed.
  • Additional boundary checks passed with Node's --disallow-code-generation-from-strings flag.
  • General root type-check commands report errors outside these changed files (ix resolution and existing bin/test/dependency typings); no compiler configuration is changed here.

The old switch-vs-Map performance claim is removed rather than retained for a different implementation. The single-sentinel fast path avoids Set lookup; multi-sentinel performance remains a review consideration. This does not claim to resolve any npm scanning hold.

@p-linnane

Copy link
Copy Markdown

@azure/storage-blob 12.34.0 depends on apache-arrow@^21.1.0, so createIsValidFunction now ships in GitHub's CodeQL Action bundle (v4.38.3 and v4.39.0), where static analysis can't verify the generated function. Could this land in a 21.x release so it reaches @azure/storage-blob through its existing range?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation matches the stated behavior, with regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

Enables Arrow builders to run where dynamic code generation is prohibited, addressing #54.

Changes:

  • Replaces generated functions with direct comparisons or snapshot Set membership.
  • Adds regression tests for sentinel matching, input mutation, and a blocked Function constructor.
  • Updates documentation and removes the generated-source serializer.
File Description
test/​unit/​builders/​valid-tests.ts Adds validity predicate regression coverage.
src/​builder/​valid.ts Implements validity predicates without dynamic compilation.

Review effort: Balanced

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.

[JS] apache-arrow doesn't work on platform restricting eval/new Function

3 participants