Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(import): surface legacy session decode errors instead of defaulting

Steven Enamakel900642c26f28
diff --git a/crates/openhuman-core/src/storage/import/session_db.rs b/crates/openhuman-core/src/storage/import/session_db.rs
index ef41af16ba..c3ddf702eb 100644
--- a/crates/openhuman-core/src/storage/import/session_db.rs
+++ b/crates/openhuman-core/src/storage/import/session_db.rs
@@ -351,7 +351,9 @@ fn read_records<T: DeserializeOwned>(
let mut object = Map::new();
for (index, field) in fields.iter().enumerate() {
let value = sql_value(row.get_ref(index)?)?;
- object.insert(field.output.to_owned(), decode_value(value, field.decode)?);
+ let value = decode_value(value, field.decode)
+ .with_context(|| format!("decode legacy column `{table}.{}`", field.column))?;
+ object.insert(field.output.to_owned(), value);
}
normalize_legacy_status(table, &mut object)?;
let record: T = serde_json::from_value(Value::Object(object))
@@ -407,25 +409,28 @@ fn read_tool_effects(connection: &rusqlite::Connection) -> Result<Vec<ToolEffect
}
fn decode_value(value: Value, decode: Decode) -> Result<Value> {
- Ok(match decode {
- Decode::Plain => value,
+ match decode {
+ Decode::Plain => Ok(value),
Decode::JsonOrEmpty => {
let raw = value.as_str().context("legacy JSON column is not text")?;
- serde_json::from_str(raw).unwrap_or_else(|_| json!({}))
+ serde_json::from_str(raw).context("parse legacy JSON column")
}
- Decode::OptionalJson => value
- .as_str()
- .and_then(|raw| serde_json::from_str(raw).ok())
- .unwrap_or(Value::Null),
+ Decode::OptionalJson => match value {
+ Value::Null => Ok(Value::Null),
+ Value::String(raw) => {
+ serde_json::from_str(&raw).context("parse optional legacy JSON column")
+ }
+ _ => bail!("optional legacy JSON column is not text or NULL"),
+ },
Decode::JsonArray => {
let raw = value
.as_str()
.context("legacy JSON array column is not text")?;
serde_json::from_str::<Vec<String>>(raw)
.map(|values| json!(values))
- .unwrap_or_else(|_| json!([]))
+ .context("parse legacy JSON array column")
}
- })
+ }
}
fn normalize_legacy_status(table: &str, row: &mut Map<String, Value>) -> Result<()> {
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 0cd5f23505..f73cb627ae 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 0cd5f23505dc0bfa492872cd38bd1a800c1c817f
+Subproject commit f73cb627aea06edd5a9787b1274b1bb1915da9bb