Skip to content

Commit 686eb87

Browse files
committed
Update KV value type
1 parent 46ed4fd commit 686eb87

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "openworkers-runner"
3-
version = "0.7.1"
3+
version = "0.7.2"
44
edition = "2024"
55
default-run = "openworkers-runner"
66

@@ -30,11 +30,11 @@ reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"
3030

3131
# Core types
3232
# openworkers-core = { path = "../openworkers-core" }
33-
openworkers-core = { git = "https://github.com/openworkers/openworkers-core", tag = "v0.7.0" }
33+
openworkers-core = { git = "https://github.com/openworkers/openworkers-core", tag = "v0.7.1" }
3434

3535
# Runtime backend (v8 only for now, others require core 0.5)
3636
# openworkers-runtime-v8 = { path = "../openworkers-runtime-v8", features = ["actix"], optional = true }
37-
openworkers-runtime-v8 = { git = "https://github.com/openworkers/openworkers-runtime-v8", tag = "v0.7.1", features = ["actix"], optional = true }
37+
openworkers-runtime-v8 = { git = "https://github.com/openworkers/openworkers-runtime-v8", tag = "v0.7.2", features = ["actix"], optional = true }
3838

3939
# Database bindings (optional)
4040
# postgate = { path = "../postgate", default-features = false, optional = true }

src/ops.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl OperationsHandler for RunnerOperations {
454454
Box::pin(async move {
455455
match op {
456456
KvOp::Get { key } => {
457-
let result = sqlx::query_scalar::<_, String>(
457+
let result = sqlx::query_scalar::<_, serde_json::Value>(
458458
r#"
459459
SELECT value FROM kv_data
460460
WHERE namespace_id = $1::uuid AND key = $2
@@ -480,6 +480,23 @@ impl OperationsHandler for RunnerOperations {
480480
value,
481481
expires_in,
482482
} => {
483+
// Check value size (100KB limit)
484+
const MAX_VALUE_SIZE: usize = 100 * 1024;
485+
let value_str = match serde_json::to_string(&value) {
486+
Ok(s) => s,
487+
Err(e) => {
488+
return KvResult::Error(format!("Invalid JSON value: {}", e));
489+
}
490+
};
491+
492+
if value_str.len() > MAX_VALUE_SIZE {
493+
return KvResult::Error(format!(
494+
"Value too large: {} bytes (max {} bytes)",
495+
value_str.len(),
496+
MAX_VALUE_SIZE
497+
));
498+
}
499+
483500
// Calculate expires_at from expires_in (seconds from now)
484501
let result = if let Some(ttl) = expires_in {
485502
sqlx::query(

0 commit comments

Comments
 (0)