Bind a lone buffer positionally instead of as named parameters - #234
Open
ivanjeremic wants to merge 1 commit into
Open
Bind a lone buffer positionally instead of as named parameters#234ivanjeremic wants to merge 1 commit into
ivanjeremic wants to merge 1 commit into
Conversation
A buffer is a JS object, so `map_params` sent it down the named-parameter path, where `stmt.parameter_name()` returns None for an anonymous '?' and the unwrap panicked out of the runtime — taking the process with it on recent builds. Passing the same buffer inside an array worked, which is why the existing blob tests did not catch it. Buffers and typed arrays now take the positional path, as they already do inside an array, and a named-parameter object offered to a statement with anonymous parameters is reported rather than unwrapped. Reproduces on 0.5.29 and 0.6.0-pre.41.
ivanjeremic
added a commit
to zelavis/zelavis
that referenced
this pull request
Sep 12, 2026
#382) Binding a lone Buffer routed it down the named-parameter path, where an anonymous '?' has no name and the unwrap panicked out of the runtime, aborting the process on 0.6.0-pre.41. Fixed in tursodatabase/libsql-js#234 from a fork under repos/libsql-js: buffers and typed arrays bind positionally, and a named-parameter object against '?' throws instead. The item is no longer "report it" but "take the keys back off hex once a release carries it". Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Author
|
Update: I've now built this locally (Rust 1.98.1, Before the patch, the second line below aborted the process. After it: So both halves hold: buffers and typed arrays bind positionally, and a named-parameter object offered to a statement with anonymous I have not run the full |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
Binding a single
Bufferto a statement panics out of the runtime:On
0.6.0-pre.41it aborts the process outright (fatal runtime error: failed to initiate panic).Why
map_paramsdecides positional vs named by JS type, and aBufferis an object:So a lone buffer goes to
map_params_object, which asks for each parameter's name. For an anonymous?that isNone, and the.unwrap()panics. Two arguments take the positional path, which is why the insert above survives and the select does not — and why the existing blob tests pass: they bind inside an array (insertStmt.run([array])), never alone.The fix
map_valuehas theis_buffer/is_typedarraychecks; this reuses them one level up.map_params_objectreports an anonymous-parameter statement instead of unwrappingNone, so genuine misuse — a named-parameter object against?placeholders — throws a JS error rather than killing the process.Tests
Added to
integration-tests/tests/sync.test.js:Buffer, aBufferinside an array, and aUint8Arrayall bind and read back the same blob;?throws rather than aborting.I could not build or run the suite locally — no Rust toolchain on the machine I wrote this on — so the change is source-reviewed only and needs your CI to confirm it. Reproduced the bug itself on both
0.5.29and0.6.0-pre.41.Related
Statement.run()with object parameter panics) is this sameunwrap, reached the other way, and the second change turns it into an error.Found while using libSQL as a key-value engine, where every key is a
Buffer; the workaround until now was encoding keys as hex text.