rest: add a test for unsuported `/blockpart/` request type
What changed, and why it matters
This commit only adds a new automated test to Bitcoin Core's REST interface test suite. It checks that the /blockpart/ endpoint correctly rejects unsupported request types with proper error messages. There is no code change to the actual REST server behavior, and no security vulnerability is being fixed.
No action required. This is a benign test-only commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/interface_rest.py to add two assertions around the existing /blockpart/ test. One verifies that a BIN request without offset/size parameters returns the expected ‘Block part offset missing or invalid’ error. The other verifies that a JSON request with valid offset/size returns ‘JSON output is not supported for this request type’. This is purely test coverage expansion; no production code is altered.
Changed components
test/functional/interface_rest.pyInspect captured patch +5 / −1
diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py
index 6b4bb797..2e9617d0 100755
--- a/test/functional/interface_rest.py
+++ b/test/functional/interface_rest.py
@@ -489,7 +489,11 @@ class RESTTest (BitcoinTestFramework):
get_block_part(status=400, query_params={"offset": len(block_bin) + 1, "size": 1})
get_block_part(status=400, query_params={"offset": 0, "size": len(block_bin) + 1})
- self.test_rest_request(f"/blockpart/{blockhash}", status=400, req_type=ReqType.JSON, ret_type=RetType.OBJ)
+ res = self.test_rest_request(f"/blockpart/{blockhash}", status=400, req_type=ReqType.BIN, ret_type=RetType.OBJ)
+ assert res.read().decode().startswith("Block part offset missing or invalid")
+
+ res = self.test_rest_request(f"/blockpart/{blockhash}", query_params={"offset":0, "size":1}, status=400, req_type=ReqType.JSON, ret_type=RetType.OBJ)
+ assert res.read().decode().startswith("JSON output is not supported for this request type")
self.log.info("Missing block data should cause REST API to fail")
Why this scored 14/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.