tursodatabase / tursodatabase/libsql-client-ts

Rust panic when executing insert with arguments

Open
#298 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
576
Forks
69
PR merge metrics
No merged PRs in 30d

Description

I am experiencing a rust panic within the libsql/client source code - here is the source code of our usage https://github.com/Makespace/members-app/blob/5a8b052587a07cdee2216b48aa8d470a4341f460/src/init-dependencies/google/get-cached-sheet-data.ts#L96

await dbClient.execute({
        sql: `
              INSERT INTO cached_sheet_data (cached_at, sheet_id, cached_data)
              VALUES ($cachedAt, $sheetId, $cachedData)
              ON CONFLICT (sheet_id) DO UPDATE SET
                cached_at = excluded.cached_at,
                cached_data = excluded.cached_data;
            `,
        args: {
          cachedAt: cacheTimestamp,
          sheetId,
          cachedData,
        },
      });

And the error

2025-02-15T17:26:55.474 app[148e200df35498] lhr [info] thread '<unnamed>' panicked at src/statement.rs:360:62:

2025-02-15T17:26:55.474 app[148e200df35498] lhr [info] called `Option::unwrap()` on a `None` value

2025-02-15T17:26:55.474 app[148e200df35498] lhr [info] stack backtrace:

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 0: 0x7f200b86a8be - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 1: 0x7f200b52768c - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 2: 0x7f200b83f6f2 - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 3: 0x7f200b86c16f - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 4: 0x7f200b86b978 - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 5: 0x7f200b86cabc - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 6: 0x7f200b86c488 - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 7: 0x7f200b86c416 - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 8: 0x7f200b86c403 - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 9: 0x7f200b496904 - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 10: 0x7f200b4969f2 - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 11: 0x7f200b496d45 - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 12: 0x7f200b51bb1e - <unknown>

2025-02-15T17:26:55.475 app[148e200df35498] lhr [info] 13: 0x7f200b4de14d - <unknown>

2025-02-15T17:26:55.491 app[148e200df35498] lhr [info] 14: 0xc51049 - _ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE

2025-02-15T17:26:55.491 app[148e200df35498] lhr [info] 15: 0xf57eaf - _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE

2025-02-15T17:26:55.491 app[148e200df35498] lhr [info] 16: 0xf5871d - _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEENS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EEPmi

2025-02-15T17:26:55.491 app[148e200df35498] lhr [info] 17: 0xf58be5 - _ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE

2025-02-15T17:26:55.495 app[148e200df35498] lhr [info] 18: 0x1963df6 - Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit

This happens everytime and I can reliably recreate it. For context I'm trying to insert a large string into the database which represents a blob of data stored as json.

Seems to match https://github.com/tursodatabase/libsql/issues/1811#issuecomment-2513855314 (I've posted on both as this repo seemed like a more appropriate place)

Versions

"@libsql/client": "^0.14.0",
"typescript": "^5.1.3"

Node 20

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the insert from the linked TypeScript usage at src/init-dependencies/google/get-cached-sheet-data.ts#L96, using the listed @libsql/client version and large JSON string. Inspect the panic at src/statement.rs:360 and compare the related libsql issue; done means the same parameterized insert no longer panics and has coverage for the large JSON argument.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, rust, typescript
Domain
api, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.