Skip to content

Commit 112d483

Browse files
Liu Yangfacebook-github-bot
authored andcommitted
Fix abort for commit sparse profile
Summary: While looking at T215145133, I noticed the chat msg immediately above was T215143512. So while I'm already there, this is my attempt to fix. Reviewed By: andreacampi Differential Revision: D70251407 fbshipit-source-id: 162092a77575b74078d3caabff1d651d12a25194
1 parent 695bbf5 commit 112d483

File tree

1 file changed

+27
-7
lines changed
  • eden/mononoke/tools/admin/src/commands/async_requests

1 file changed

+27
-7
lines changed

eden/mononoke/tools/admin/src/commands/async_requests/abort.rs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ use anyhow::Result;
1212
use async_requests::types::AsynchronousRequestResult;
1313
use async_requests::types::RowId;
1414
use async_requests::types::ThriftAsynchronousRequestParams;
15+
use async_requests::types::ThriftAsynchronousRequestResult;
1516
use async_requests::AsyncMethodRequestQueue;
1617
use clap::Args;
1718
use context::CoreContext;
1819
use megarepo_error::MegarepoError;
1920
use mononoke_api::MononokeRepo;
2021
use source_control as thrift;
22+
use source_control::AsyncRequestError;
2123

2224
#[derive(Args)]
2325
/// Changes the request status to ready and put error as result.
@@ -41,24 +43,42 @@ pub async fn abort_request(
4143
.context("retrieving the request")?
4244
{
4345
if maybe_result.is_none() {
44-
let err = MegarepoError::InternalError(anyhow!("aborted from CLI!").into());
46+
let megarepo_err = MegarepoError::InternalError(anyhow!("aborted from CLI!").into());
47+
let default_err =
48+
AsynchronousRequestResult::from_thrift(ThriftAsynchronousRequestResult::error(
49+
AsyncRequestError::internal_error(thrift::InternalErrorStruct {
50+
reason: String::from("aborted from CLI!"),
51+
backtrace: None,
52+
source_chain: vec![],
53+
..Default::default()
54+
}),
55+
));
4556
let result: AsynchronousRequestResult = match params.thrift() {
4657
ThriftAsynchronousRequestParams::megarepo_sync_changeset_params(_) => {
47-
thrift::MegarepoSyncChangesetResult::error(err.into()).into()
58+
thrift::MegarepoSyncChangesetResult::error(megarepo_err.into()).into()
4859
}
4960
ThriftAsynchronousRequestParams::megarepo_add_target_params(_) => {
50-
thrift::MegarepoAddTargetResult::error(err.into()).into()
61+
thrift::MegarepoAddTargetResult::error(megarepo_err.into()).into()
5162
}
5263
ThriftAsynchronousRequestParams::megarepo_change_target_params(_) => {
53-
thrift::MegarepoChangeTargetConfigResult::error(err.into()).into()
64+
thrift::MegarepoChangeTargetConfigResult::error(megarepo_err.into()).into()
5465
}
5566
ThriftAsynchronousRequestParams::megarepo_remerge_source_params(_) => {
56-
thrift::MegarepoRemergeSourceResult::error(err.into()).into()
67+
thrift::MegarepoRemergeSourceResult::error(megarepo_err.into()).into()
5768
}
5869
ThriftAsynchronousRequestParams::megarepo_add_branching_target_params(_) => {
59-
thrift::MegarepoAddBranchingTargetResult::error(err.into()).into()
70+
thrift::MegarepoAddBranchingTargetResult::error(megarepo_err.into()).into()
71+
}
72+
ThriftAsynchronousRequestParams::commit_sparse_profile_size_params(_) => {
73+
default_err
74+
}
75+
ThriftAsynchronousRequestParams::commit_sparse_profile_delta_params(_) => {
76+
default_err
77+
}
78+
ThriftAsynchronousRequestParams::async_ping_params(_) => default_err,
79+
ThriftAsynchronousRequestParams::UnknownField(_) => {
80+
return Err(anyhow!("unknown request type!"));
6081
}
61-
_ => return Err(anyhow!("unknown request type!")),
6282
};
6383
queue
6484
.complete(&ctx, &request_id, result)

0 commit comments

Comments
 (0)