You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Native bulk operations lack batch cardinality guards and diverge from WASM partial-failure behavior #746
Already tracked in #743 for the whole repo — repeated here only because it is one of the two things #741 fixed locally and left unfixed natively. A non-Error rejection still becomes Error("Something went wrong") in packages/stack/src/encryption/operations/* and packages/protect/src/ffi/operations/*.
2. Native bulk ops match FFI results positionally, unguarded
packages/stack/src/encryption/operations/bulk-decrypt.ts and its siblings pair FFI results to inputs by index with no length assertion. A short response makes decryptResultundefined, and:
// bulk-decrypt.ts:49if('error'indecryptResult){
throws TypeError: Cannot use 'in' operator ... undefined — a bewildering error that names nothing about the real problem. The WASM entry now fails closed here with a message naming the counts (assertBatchLength).
3. Divergent partial-failure contract between the two entries
Native bulkDecrypt returns per-item { id, data } / { id, error }, preserving partial success. The WASM one collapses any failure into a single { failure } listing every bad index. Same operation name, different contracts — worth a deliberate decision rather than an accident of two implementations.
Suggested shape
Hoist the three helpers #741 added — toError, toFailure, assertBatchLength — into @/encryption/helpers and use them from both entries, so the guarantees are shared rather than re-derived. That also removes the risk of the next batch method on either side omitting the length assert.
Not urgent
Nothing here is a live incident: the FFI does not currently return short batches, and non-Error rejections are rare on the native path (protect-ffi throws real ProtectError instances there — unlike the WASM build, which ships no error class, which is why #741 hit it first).
changed the title [-]Native entry: withResult omits onException, bulk ops match FFI results positionally without a guard[/-][+]Native bulk operations lack batch cardinality guards and diverge from WASM partial-failure behavior[/+]on Sep 17, 2026
Run 3 scope decision: this remains merely related to #743, not blocked by it and not its child.
#743 owns repo-wide normalization of non-Error exceptions. This issue owns the independent native bulk-operation invariants: checking result cardinality before positional matching and defining partial-failure behavior consistently with the WASM entry.
Activity
[-]Native entry: withResult omits onException, bulk ops match FFI results positionally without a guard[/-][+]Native bulk operations lack batch cardinality guards and diverge from WASM partial-failure behavior[/+]tobyhede commentedon Sep 17, 2026
Run 3 scope decision: this remains merely related to #743, not blocked by it and not its child.
#743 owns repo-wide normalization of non-
Errorexceptions. This issue owns the independent native bulk-operation invariants: checking result cardinality before positional matching and defining partial-failure behavior consistently with the WASM entry.