fix: discard legacy top-level run generation
This commit is contained in:
@@ -675,6 +675,14 @@ fn migrate_worker_document(
|
||||
"Worker snapshot must be an object".to_string(),
|
||||
)
|
||||
})?;
|
||||
if let Some(run_generation) = object.remove("run_generation")
|
||||
&& run_generation.as_u64().is_none()
|
||||
{
|
||||
return Err(runtime_store_corrupt(
|
||||
snapshot_path,
|
||||
"Worker snapshot run_generation must be an unsigned integer".to_string(),
|
||||
));
|
||||
}
|
||||
let execution = object
|
||||
.get_mut("execution")
|
||||
.and_then(serde_json::Value::as_object_mut)
|
||||
@@ -1665,6 +1673,7 @@ mod tests {
|
||||
let path = Path::new("worker.json");
|
||||
let source = serde_json::json!({
|
||||
"schema_version": PREVIOUS_SCHEMA_VERSION,
|
||||
"run_generation": 7,
|
||||
"status": "running",
|
||||
"execution": {
|
||||
"last_run_generation": 7,
|
||||
@@ -1680,6 +1689,7 @@ mod tests {
|
||||
assert_eq!(migrated["status"], "running");
|
||||
assert_eq!(migrated["execution"]["binding"], serde_json::json!({}));
|
||||
assert_eq!(migrated["execution"]["restore_intent"], "automatic");
|
||||
assert!(migrated.get("run_generation").is_none());
|
||||
assert!(migrated["execution"].get("last_run_generation").is_none());
|
||||
}
|
||||
|
||||
|
||||
@@ -7207,6 +7207,7 @@ mod tests {
|
||||
let mut worker_json: serde_json::Value =
|
||||
serde_json::from_slice(&std::fs::read(&worker_path).unwrap()).unwrap();
|
||||
worker_json["schema_version"] = serde_json::json!(6);
|
||||
worker_json["run_generation"] = serde_json::json!(1);
|
||||
worker_json["execution"]["last_run_generation"] = serde_json::json!(1);
|
||||
worker_json["execution"]["binding"] = serde_json::json!({"run_generation": 1});
|
||||
std::fs::write(
|
||||
@@ -7227,6 +7228,7 @@ mod tests {
|
||||
serde_json::from_slice(&std::fs::read(&worker_path).unwrap()).unwrap();
|
||||
assert_eq!(migrated_json["schema_version"], serde_json::json!(7));
|
||||
assert_eq!(migrated_json["execution"]["binding"], serde_json::json!({}));
|
||||
assert!(migrated_json.get("run_generation").is_none());
|
||||
assert!(
|
||||
migrated_json["execution"]
|
||||
.get("last_run_generation")
|
||||
|
||||
Reference in New Issue
Block a user