tauri-apps / tauri-apps/plugins-workspace
BLOB values are returned as JSON strings instead of arrays in TypeScript
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
### Describe the bug
I'm not sure whether this is expected behavior or if I'm doing something wrong, so I wanted to ask before assuming it's a bug.
BLOB values are returned as JSON strings instead of arrays in TypeScript
### Reproduction
await db.execute("CREATE TABLE IF NOT EXISTS test(b BLOB)");
await db.execute("INSERT INTO test VALUES (?)", [
new Uint8Array([1, 2, 3, 4]),
]);
const r = await db.select("SELECT b FROM test");
console.log(typeof r[0].b);
console.log(r[0].b);
Actual output
string
"[1,2,3,4]"
### Expected behavior
I expected one of the following:
number[]
Uint8Array
or any other structured binary representation
Instead, the returned value is a JSON-encoded string that requires an additional JSON.parse() before it can be used.
### Full `tauri info` output
```text
[✔] Environment
- OS: Ubuntu 24.4.0 x86_64 (X64) (KDE on x11)
✔ webkit2gtk-4.1: 2.52.3
✔ rsvg2: 2.58.0
✔ rustc: 1.93.0 (254b59607 2026-01-19)
✔ cargo: 1.93.0 (083ac5135 2025-12-15)
✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
- node: 24.4.1
- npm: 11.4.2
[-] Packages
- tauri 🦀: 2.11.5
- tauri-build 🦀: 2.6.3
- wry 🦀: 0.55.1
- tao 🦀: 0.35.3
- @tauri-apps/api ⱼₛ: 2.11.0 (outdated, latest: 2.11.1)
- @tauri-apps/cli ⱼₛ: 2.11.0 (outdated, latest: 2.11.4)
[-] Plugins
- tauri-plugin-http 🦀: 2.5.9
- @tauri-apps/plugin-http ⱼₛ: 2.5.8 (outdated, latest: 2.5.9)
- tauri-plugin-sql 🦀: 2.4.0
- @tauri-apps/plugin-sql ⱼₛ: 2.4.0
- tauri-plugin-fs 🦀: 2.5.1
- @tauri-apps/plugin-fs ⱼₛ: not installed!
- tauri-plugin-opener 🦀: 2.5.4
- @tauri-apps/plugin-opener ⱼₛ: 2.5.3 (outdated, latest: 2.5.4)
```
### Stack trace
```text
```
### Additional context
I checked the implementation in the repository and noticed that SQLite BLOB values are decoded as:
JsonValue::Array(...)
which made me expect that TypeScript would receive an array rather than a string.
I also verified using an external SQLite browser that the value is actually stored as a BLOB in the database.
So my question is:
Is this the intended behavior?
Or is this an issue in the serialization between Rust and TypeScript?
If this is expected, I'd appreciate understanding the reasoning behind returning a JSON string instead of an array.
Thanks!
Contributor guide
Research direction
Start with the TypeScript db.select reproduction and trace the SQLite BLOB decoding that produces JsonValue::Array across the Rust-to-TypeScript serialization boundary. Confirm where the array becomes a JSON string, then establish the intended structured binary representation and verify that BLOB queries return it without requiring JSON.parse().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sqlite, typescript
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100