Skip to content

Commit 95f22c1

Browse files
authored
[release/6.x] Respond with available snapshot rather than Bad Request error (#7415)
1 parent 768a66c commit 95f22c1

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313

1414
- Stop passing nullptr to curl_multi_socket_action (#7371)
1515

16+
### Changed
17+
18+
- When `GET /node/snapshot/{snapshot_name}` requests a `Range` that extends beyond the snapshot's end, the node will now respond with the available sub-range rather than a Bad Request error.
19+
1620
## [6.0.15]
1721

1822
[6.0.15]: https://github.com/microsoft/CCF/releases/tag/6.0.15

src/node/rpc/node_frontend.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,14 +2092,12 @@ namespace ccf
20922092

20932093
if (range_end > total_size)
20942094
{
2095-
ctx.rpc_ctx->set_error(
2096-
HTTP_STATUS_BAD_REQUEST,
2097-
ccf::errors::InvalidHeaderValue,
2098-
fmt::format(
2099-
"End of range {} is larger than total file size {}",
2100-
range_end,
2101-
total_size));
2102-
return;
2095+
LOG_DEBUG_FMT(
2096+
"Requested snapshot range ending at {}, but file size is "
2097+
"only {} - shrinking range end",
2098+
range_end,
2099+
total_size);
2100+
range_end = total_size;
21032101
}
21042102

21052103
if (range_end < range_start)

tests/e2e_operations.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ def test_snapshot_access(network, args):
352352
("foo-foo", "Unable to parse start of range value foo"),
353353
(f"foo-{b}", "Unable to parse start of range value foo"),
354354
(f"{b}-{a}", "out of order"),
355-
(f"0-{total_size + 1}", "larger than total file size"),
356355
("-1-5", "Invalid format"),
357356
("-", "Invalid range"),
358357
("-foo", "Unable to parse end of range offset value foo"),

0 commit comments

Comments
 (0)