继续传播 Direct 工具任务错误
保留上下文验证补丁 worker 和 OAuth 解析原因 通过 Direct 验证定向测试
This commit is contained in:
+10
-7
@@ -47,9 +47,9 @@ fn oauth_identity(auth: &Value) -> Result<OAuthIdentity, String> {
|
||||
.ok_or("model-catalog-auth-handoff-identity")?;
|
||||
let payload = base64::engine::general_purpose::URL_SAFE_NO_PAD
|
||||
.decode(payload.trim_end_matches('='))
|
||||
.map_err(|_| "model-catalog-auth-handoff-identity")?;
|
||||
let claims: Value =
|
||||
serde_json::from_slice(&payload).map_err(|_| "model-catalog-auth-handoff-identity")?;
|
||||
.map_err(|error| format!("model-catalog-auth-handoff-identity:{error}"))?;
|
||||
let claims: Value = serde_json::from_slice(&payload)
|
||||
.map_err(|error| format!("model-catalog-auth-handoff-identity:{error}"))?;
|
||||
let claims_auth = &claims["https://api.openai.com/auth"];
|
||||
let token_account = auth
|
||||
.pointer("/tokens/account_id")
|
||||
@@ -87,12 +87,13 @@ fn oauth_bytes(bytes: &[u8]) -> Result<(OAuthIdentity, Vec<u8>), String> {
|
||||
if bytes.len() > MAX_AUTH_BYTES as usize {
|
||||
return Err("model-catalog-auth-handoff-size".into());
|
||||
}
|
||||
let mut auth: Value =
|
||||
serde_json::from_slice(bytes).map_err(|_| "model-catalog-auth-handoff-invalid")?;
|
||||
let mut auth: Value = serde_json::from_slice(bytes)
|
||||
.map_err(|error| format!("model-catalog-auth-handoff-invalid:{error}"))?;
|
||||
let identity = oauth_identity(&auth)?;
|
||||
// 显式 OAuth 文件可能还残留一个 API Key;私有轮换缓存从不携带它。
|
||||
auth["OPENAI_API_KEY"] = Value::Null;
|
||||
let bytes = serde_json::to_vec(&auth).map_err(|_| "model-catalog-auth-handoff-invalid")?;
|
||||
let bytes = serde_json::to_vec(&auth)
|
||||
.map_err(|error| format!("model-catalog-auth-handoff-invalid:{error}"))?;
|
||||
Ok((identity, bytes))
|
||||
}
|
||||
|
||||
@@ -181,7 +182,9 @@ impl OAuthHandoff {
|
||||
MAX_AUTH_BYTES,
|
||||
)
|
||||
})
|
||||
.map_err(|_| "model-catalog-auth-handoff-read: 无法确认私有 OAuth 轮换状态".to_string())
|
||||
.map_err(|error| {
|
||||
format!("model-catalog-auth-handoff-read: 无法确认私有 OAuth 轮换状态:{error}")
|
||||
})
|
||||
.and_then(|text| oauth_bytes(text.as_bytes()))
|
||||
.and_then(|(identity, bytes)| {
|
||||
if identity != self.identity {
|
||||
|
||||
@@ -380,7 +380,7 @@ pub(super) async fn apply(root: &Path, arguments: &Value) -> Result<Value, Strin
|
||||
Ok::<_, String>((root, session, result))
|
||||
})
|
||||
.await
|
||||
.map_err(|_| "patch-worker-exited: 补丁事务任务退出,结果需要核对")??;
|
||||
.map_err(|error| format!("patch-worker-exited: 补丁事务任务退出,结果需要核对:{error}"))??;
|
||||
if result["status"] == "completed" {
|
||||
let _ = direct_delivery::try_seal(&root, &session).await;
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ where
|
||||
context_identity(&identity_root)
|
||||
})
|
||||
.await
|
||||
.map_err(|_| "项目上下文读取任务中断")??;
|
||||
.map_err(|error| format!("项目上下文读取任务中断:{error}"))??;
|
||||
let item_budget = MAX_ITEM_BYTES.min(response_budget.saturating_sub(4096) / files.len());
|
||||
let reader = Arc::new(reader);
|
||||
let root = root.to_path_buf();
|
||||
@@ -428,7 +428,7 @@ where
|
||||
let path = request.path.clone();
|
||||
let item = tokio::task::spawn_blocking(move || reader(&root, &request, item_budget))
|
||||
.await
|
||||
.map_err(|_| "文件批量读取任务中断".to_string())?;
|
||||
.map_err(|error| format!("文件批量读取任务中断:{error}"))?;
|
||||
Ok::<_, String>((index, path, item))
|
||||
}
|
||||
}))
|
||||
@@ -463,10 +463,10 @@ where
|
||||
.collect::<HashSet<_>>()
|
||||
})
|
||||
.await
|
||||
.map_err(|_| "批量读取复核任务中断")?;
|
||||
.map_err(|error| format!("批量读取复核任务中断:{error}"))?;
|
||||
let after = tokio::task::spawn_blocking(move || context_identity(&root))
|
||||
.await
|
||||
.map_err(|_| "项目上下文复核任务中断")??;
|
||||
.map_err(|error| format!("项目上下文复核任务中断:{error}"))??;
|
||||
let stale = before.project_id != after.project_id
|
||||
|| before.revision != after.revision
|
||||
|| before.turn_id != after.turn_id
|
||||
@@ -483,7 +483,7 @@ where
|
||||
"status":if stale {"stale"} else {"ready"},"activity":before.activity,"turnStatus":before.status,
|
||||
"capturedAt":unix_millis().min(u128::from(u64::MAX)) as u64,"atomicSnapshot":false,"files":files});
|
||||
if serde_json::to_vec(&result)
|
||||
.map_err(|_| "上下文序列化失败")?
|
||||
.map_err(|error| format!("上下文序列化失败:{error}"))?
|
||||
.len()
|
||||
> response_budget
|
||||
{
|
||||
@@ -533,7 +533,7 @@ pub(super) async fn prefetch_turn_input(
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.await
|
||||
.map_err(|_| "项目预取扫描任务中断")?;
|
||||
.map_err(|error| format!("项目预取扫描任务中断:{error}"))?;
|
||||
if files.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ async fn start_for_current_turn(
|
||||
reserve(&root, session, &key, &fingerprint, &source, build)
|
||||
})
|
||||
.await
|
||||
.map_err(|_| "验证预约任务退出".to_string())?
|
||||
.map_err(|error| format!("验证预约任务退出:{error}"))?
|
||||
}
|
||||
|
||||
async fn finish_async(
|
||||
@@ -393,7 +393,7 @@ async fn finish_async(
|
||||
let root = root.to_path_buf();
|
||||
tokio::task::spawn_blocking(move || finish(&root, &reservation, result, passed))
|
||||
.await
|
||||
.map_err(|_| "验证回执任务退出".to_string())?
|
||||
.map_err(|error| format!("验证回执任务退出:{error}"))?
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
||||
Reference in New Issue
Block a user