fix: preserve workdir failure diagnostics across transport
This commit is contained in:
@@ -158,11 +158,15 @@ async fn command_page(
|
||||
) -> Result<workdir::CommandOutput, workdir::WorkdirError> {
|
||||
for attempt in 0..3 {
|
||||
match session.command_output(request.clone()).await {
|
||||
Err(
|
||||
workdir::WorkdirError::Transport(_)
|
||||
| workdir::WorkdirError::Unavailable(_)
|
||||
| workdir::WorkdirError::OutcomeUnknown(_),
|
||||
) if attempt < 2 => {
|
||||
Err(error)
|
||||
if attempt < 2
|
||||
&& matches!(
|
||||
error.classification_source(),
|
||||
workdir::WorkdirError::Transport(_)
|
||||
| workdir::WorkdirError::Unavailable(_)
|
||||
| workdir::WorkdirError::OutcomeUnknown(_)
|
||||
) =>
|
||||
{
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100 << attempt)).await;
|
||||
}
|
||||
result => return result,
|
||||
|
||||
@@ -147,7 +147,9 @@ impl FileTarget {
|
||||
pub(crate) fn checked_error(error: workdir::WorkdirError) -> ToolError {
|
||||
use workdir::WorkdirError;
|
||||
let code = match error.classification_source() {
|
||||
WorkdirError::DenialContext { .. } => unreachable!("diagnostic context unwrapped"),
|
||||
WorkdirError::DenialContext { .. } | WorkdirError::FailureContext { .. } => {
|
||||
unreachable!("diagnostic context unwrapped")
|
||||
}
|
||||
WorkdirError::Conflict(_) | WorkdirError::NotFound(_) => "checkout_stale",
|
||||
WorkdirError::Denied { .. }
|
||||
| WorkdirError::OutOfScope { .. }
|
||||
|
||||
@@ -546,9 +546,10 @@ impl workdir::WorkdirSession for ExternalValidatingSession {
|
||||
.is_ok()
|
||||
{
|
||||
// The production provider has committed a page, but its response is lost.
|
||||
return Err(workdir::WorkdirError::Transport(
|
||||
"injected lost response".into(),
|
||||
));
|
||||
return Err(
|
||||
workdir::WorkdirError::Transport("injected lost response".into())
|
||||
.with_failure_reason(workdir::WorkdirFailureReason::HttpTimeout),
|
||||
);
|
||||
}
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user