Skip to content

Commit 0e83ea3

Browse files
committed
Accept true/false for --fix-block-reorgs (DX-5694)
The flag took a raw 0/1 integer. It now parses as a bool via clap's BoolishValueParser, so the documented form is true/false while 0/1 (and yes/no) keep working. The value still maps to the integer the streams API expects.
1 parent 092ec0d commit 0e83ea3

3 files changed

Lines changed: 45 additions & 4 deletions

File tree

src/commands/stream/actions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ fn build_create_params(a: CreateArgs) -> Result<CreateStreamParams, CliError> {
9292
status: a.status.map(Into::into),
9393
notification_email: a.notification_email,
9494
charge_min_cap: None,
95-
fix_block_reorgs: a.fix_block_reorgs,
95+
// The API models this as 0/1.
96+
fix_block_reorgs: a.fix_block_reorgs.map(i32::from),
9697
elastic_batch_enabled: a.elastic_batch_enabled.unwrap_or(false),
9798
extra_destinations: None,
9899
})

src/commands/stream/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ pub struct CreateArgs {
131131
/// dataset_batch_size (defaults to 1).
132132
#[arg(long)]
133133
pub batch_size: Option<i64>,
134-
/// fix_block_reorgs (0/1).
135-
#[arg(long)]
136-
pub fix_block_reorgs: Option<i32>,
134+
/// Fix block reorgs (true/false).
135+
#[arg(long, value_parser = clap::builder::BoolishValueParser::new())]
136+
pub fix_block_reorgs: Option<bool>,
137137
/// elastic_batch_enabled.
138138
#[arg(long)]
139139
pub elastic_batch_enabled: Option<bool>,

tests/streams.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,46 @@ async fn create_stream_webhook_destination() {
8181
assert_eq!(out.exit_code, 0, "stderr={}", out.stderr);
8282
}
8383

84+
#[tokio::test]
85+
async fn create_stream_fix_block_reorgs_accepts_bool_and_sends_int() {
86+
let server = MockServer::start().await;
87+
Mock::given(method("POST"))
88+
.and(path("/streams/rest/v1/streams"))
89+
.and(body_partial_json(json!({ "fix_block_reorgs": 1 })))
90+
.respond_with(ResponseTemplate::new(200).set_body_json(stream_payload("s-new")))
91+
.expect(2)
92+
.mount(&server)
93+
.await;
94+
// `true` is the documented form; bare `1` keeps working via the boolish parser.
95+
for value in ["true", "1"] {
96+
let out = run_qn(
97+
&server.uri(),
98+
&[
99+
"stream",
100+
"create",
101+
"--name",
102+
"s1",
103+
"--network",
104+
"ethereum-mainnet",
105+
"--dataset",
106+
"block",
107+
"--start",
108+
"100",
109+
"--end",
110+
"-1",
111+
"--region",
112+
"usa-east",
113+
"--webhook",
114+
"https://hook.example/x",
115+
"--fix-block-reorgs",
116+
value,
117+
],
118+
)
119+
.await;
120+
assert_eq!(out.exit_code, 0, "value={value} stderr={}", out.stderr);
121+
}
122+
}
123+
84124
#[tokio::test]
85125
async fn create_stream_webhook_destination_with_gzip() {
86126
let server = MockServer::start().await;

0 commit comments

Comments
 (0)