From 50bec171983b6fe05a2442fb812e3f35cd8e6067 Mon Sep 17 00:00:00 2001 From: Dv2Corn <320380254+Dv2Corn@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:53:50 +0000 Subject: [PATCH 1/4] fix(rest): report a node answer without an HTTP/1.1 status line clearly When something in front of a REST node answers with HTTP/2 frames, an HTTP/2 status line, TLS bytes or anything else that is not an HTTP/1.x status line, aiohttp's parser raises ClientResponseError with status 400 and its own parser text. _handle_error passed that on as NodeAPIError(400, "HTTP error: Bad status line: Expected HTTP/, RTSP/ or ICE/: b'...'"), which reads as if the node had answered 400. A ClientResponseError caused by aiohttp's BadStatusLine is now raised as NodeAPIError(-2, "Protocol error: Node did not answer with HTTP/1.1 (got HTTP/2 | TLS data | the first bytes); the REST API needs HTTP/1.1, check the reverse proxy and TLS settings"), the code the bridge already uses for connection and network errors. Real HTTP error statuses, empty answers and other errors keep their current codes and texts. Opening the log stream goes through the same handler. --- PasarGuardNodeBridge/rest.py | 37 ++++++++++ tests/test_rest_protocol_errors.py | 115 +++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 tests/test_rest_protocol_errors.py diff --git a/PasarGuardNodeBridge/rest.py b/PasarGuardNodeBridge/rest.py index ae57aca..3c706ba 100644 --- a/PasarGuardNodeBridge/rest.py +++ b/PasarGuardNodeBridge/rest.py @@ -1,10 +1,13 @@ +import ast import asyncio import logging +import re from collections.abc import AsyncGenerator from contextlib import asynccontextmanager from typing import TypeVar, overload import aiohttp +from aiohttp.http_exceptions import BadStatusLine, HttpProcessingError from google.protobuf.message import DecodeError, Message from PasarGuardNodeBridge.abstract_node import PasarGuardNode @@ -16,6 +19,37 @@ ProtoMessageT = TypeVar("ProtoMessageT", bound=Message) +# aiohttp's C parser quotes the bytes it could not parse as a Python bytes literal +_QUOTED_BYTES = re.compile(r"b'(?:[^'\\\n]|\\.)*'|b\"(?:[^\"\\\n]|\\.)*\"") + + +def _describe_non_http11_answer(error: aiohttp.ClientResponseError) -> str | None: + """Describe an answer without an HTTP/1.x status line, or return None for any other error.""" + parse_error = error.__cause__ + bad_status_line = getattr(parse_error, "__cause__", None) + if not isinstance(parse_error, HttpProcessingError) or not isinstance(bad_status_line, BadStatusLine): + return None + # The pure-Python parser keeps the status line in .line, the C parser quotes the bytes in the message + received = (bad_status_line.line or "").encode(errors="replace") + if not received and (match := _QUOTED_BYTES.search(bad_status_line.message or "")): + try: + received = ast.literal_eval(match.group()) + except (SyntaxError, ValueError): + received = b"" + + if received.startswith((b"HTTP/2", b"HTTP/3", b"PRI * HTTP/2.0")) or (len(received) >= 9 and received[3] in (4, 7)): + got = "HTTP/2" # a status line, the client preface, or a SETTINGS/GOAWAY frame + elif received[:1] in (b"\x15", b"\x16") and received[1:2] == b"\x03": + got = "TLS data" + elif received: + got = repr(received[:32]) + else: + got = "an unparsable response" + return ( + f"Node did not answer with HTTP/1.1 (got {got}); the REST API needs HTTP/1.1, " + "check the reverse proxy and TLS settings" + ) + class Node(PasarGuardNode): def __init__( @@ -96,6 +130,9 @@ def _handle_error(self, error: BaseException): raise NodeAPIError(code=-2, detail=f"Network error: {error}") elif isinstance(error, BufferedStatusError): raise NodeAPIError(code=error.response.status_code, detail=f"HTTP error: {error.response.text}") + elif isinstance(error, aiohttp.ClientResponseError) and (detail := _describe_non_http11_answer(error)): + # aiohttp reports an answer it cannot parse as status 400, but the node never sent a status + raise NodeAPIError(code=-2, detail=f"Protocol error: {detail}") elif isinstance(error, aiohttp.ClientResponseError): raise NodeAPIError(code=error.status, detail=f"HTTP error: {error.message}") else: diff --git a/tests/test_rest_protocol_errors.py b/tests/test_rest_protocol_errors.py new file mode 100644 index 0000000..ac30c4c --- /dev/null +++ b/tests/test_rest_protocol_errors.py @@ -0,0 +1,115 @@ +"""A REST node behind something that does not answer with HTTP/1.1 gets a readable error, not aiohttp's parser text.""" + +import asyncio +import logging +import unittest +from unittest.mock import patch + +from aiohttp import http_parser + +from PasarGuardNodeBridge import NodeAPIError +from PasarGuardNodeBridge.aiohttp_compat import LazyClientSession, make_timeout +from PasarGuardNodeBridge.rest import Node as RestNode +from PasarGuardNodeBridge.storage import InMemoryUserSyncStore + +# What a server sends first on an HTTP/2-only port: a SETTINGS frame, here followed by GOAWAY +HTTP2_FRAMES = bytes.fromhex("000006040000000000000300000064") + bytes.fromhex("000008070000000000000000000000000001") +# The start of a TLS record (a handshake, as a TLS-only port would send), received over plain HTTP +TLS_RECORD = bytes.fromhex("160303007a020000760303") +# aiohttp's C parser rejects such bytes at once; the pure-Python one waits for a header block and sees a closed connection +C_PARSER = http_parser.HttpResponseParser.__module__ == "aiohttp._http_parser" + + +class RestProtocolErrorTests(unittest.IsolatedAsyncioTestCase): + async def asyncSetUp(self): + self.answer = b"" + self.server = await asyncio.start_server(self.handle, "127.0.0.1", 0) + port = self.server.sockets[0].getsockname()[1] + with patch("ssl.SSLContext.load_verify_locations"): + self.node = RestNode( + address="127.0.0.1", + port=port, + api_port=1, + server_ca="test", + api_key="00000000-0000-0000-0000-000000000000", + node_id="protocol", + user_sync_store=InMemoryUserSyncStore(), + logger=logging.getLogger("rest-protocol-test"), + ) + await self.node._client.close() + self.node._client = LazyClientSession( + ssl_context=None, + headers={"Content-Type": "application/x-protobuf"}, + base_url=f"http://127.0.0.1:{port}/", + timeout=make_timeout(None), + ) + + async def asyncTearDown(self): + await self.node._client.close() + await self.node._json_client.close() + self.server.close() + await self.server.wait_closed() + + async def handle(self, reader, writer): + await reader.readuntil(b"\r\n\r\n") + if self.answer: + writer.write(self.answer) + await writer.drain() + writer.close() + await writer.wait_closed() + + async def request_error(self) -> NodeAPIError: + with self.assertRaises(NodeAPIError) as caught: + await self.node.info(timeout=5) + return caught.exception + + @unittest.skipUnless(C_PARSER, "needs aiohttp's C HTTP parser") + async def test_http2_answer_is_reported_as_protocol_error(self): + self.answer = HTTP2_FRAMES + error = await self.request_error() + self.assertEqual(error.code, -2) + self.assertIn("did not answer with HTTP/1.1 (got HTTP/2)", error.detail) + self.assertIn("check the reverse proxy and TLS settings", error.detail) + self.assertNotIn("Expected HTTP/", error.detail) + + async def test_http2_status_line_is_reported_as_protocol_error(self): + self.answer = b"HTTP/2 200\r\ncontent-length: 0\r\n\r\n" + error = await self.request_error() + self.assertEqual(error.code, -2) + self.assertIn("(got HTTP/2)", error.detail) + + @unittest.skipUnless(C_PARSER, "needs aiohttp's C HTTP parser") + async def test_tls_answer_is_reported_as_protocol_error(self): + self.answer = TLS_RECORD + error = await self.request_error() + self.assertEqual(error.code, -2) + self.assertIn("(got TLS data)", error.detail) + + async def test_other_bytes_are_quoted(self): + self.answer = b"SSH-2.0-OpenSSH_9.6\r\n\r\n" + error = await self.request_error() + self.assertEqual(error.code, -2) + self.assertIn("(got b'SSH-2.0-OpenSSH_9.6')", error.detail) + + async def test_empty_close_is_still_reported_as_closed_connection(self): + error = await self.request_error() + self.assertEqual(error.code, 500) + self.assertIn("Server closed connection", error.detail) + + async def test_http_error_status_is_unchanged(self): + self.answer = b"HTTP/1.1 400 Bad Request\r\ncontent-length: 8\r\nconnection: close\r\n\r\nbad body" + error = await self.request_error() + self.assertEqual(error.code, 400) + self.assertEqual(error.detail, "HTTP error: bad body") + + async def test_log_stream_open_reports_protocol_error(self): + self.answer = b"HTTP/2 200\r\ncontent-type: text/plain\r\n\r\n" + with self.assertRaises(NodeAPIError) as caught: + async with self.node.stream_logs(): + pass + self.assertEqual(caught.exception.code, -2) + self.assertIn("(got HTTP/2)", caught.exception.detail) + + +if __name__ == "__main__": + unittest.main() From 6913726ae8ccfb59e8b03a18be516ec11f696658 Mon Sep 17 00:00:00 2001 From: Dv2Corn <320380254+Dv2Corn@users.noreply.github.com> Date: Sun, 8 Nov 2026 13:38:16 +1000 Subject: [PATCH 2/4] fix(rest): keep 400 for malformed HTTP/1.x status lines, check HTTP/2 frame header fully A status line that starts with HTTP/1. but is malformed is reported as before (status 400, "HTTP error: ..."). An HTTP/2 SETTINGS/GOAWAY frame is recognised only when its stream id is 0 and its length fits the frame type and the initial max frame size, not by the type byte alone. --- PasarGuardNodeBridge/rest.py | 15 ++++++++++++++- tests/test_rest_protocol_errors.py | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/PasarGuardNodeBridge/rest.py b/PasarGuardNodeBridge/rest.py index 3c706ba..4375265 100644 --- a/PasarGuardNodeBridge/rest.py +++ b/PasarGuardNodeBridge/rest.py @@ -23,6 +23,17 @@ _QUOTED_BYTES = re.compile(r"b'(?:[^'\\\n]|\\.)*'|b\"(?:[^\"\\\n]|\\.)*\"") +def _is_http2_control_frame(data: bytes) -> bool: + """True if data starts with a SETTINGS or GOAWAY frame header as a server sends first (RFC 9113, 4.1 / 6.5 / 6.8).""" + if len(data) < 9: + return False + length = int.from_bytes(data[:3], "big") + stream_id = int.from_bytes(data[5:9], "big") & 0x7FFFFFFF # the top bit is reserved + if stream_id != 0 or length > 16384: # both frames belong to stream 0; 16384 is the initial max frame size + return False + return (data[3] == 0x4 and length % 6 == 0) or (data[3] == 0x7 and length >= 8) + + def _describe_non_http11_answer(error: aiohttp.ClientResponseError) -> str | None: """Describe an answer without an HTTP/1.x status line, or return None for any other error.""" parse_error = error.__cause__ @@ -37,7 +48,9 @@ def _describe_non_http11_answer(error: aiohttp.ClientResponseError) -> str | Non except (SyntaxError, ValueError): received = b"" - if received.startswith((b"HTTP/2", b"HTTP/3", b"PRI * HTTP/2.0")) or (len(received) >= 9 and received[3] in (4, 7)): + if received.startswith(b"HTTP/1."): + return None # a malformed HTTP/1.x status line keeps the usual 400 mapping + if received.startswith((b"HTTP/2", b"HTTP/3", b"PRI * HTTP/2.0")) or _is_http2_control_frame(received): got = "HTTP/2" # a status line, the client preface, or a SETTINGS/GOAWAY frame elif received[:1] in (b"\x15", b"\x16") and received[1:2] == b"\x03": got = "TLS data" diff --git a/tests/test_rest_protocol_errors.py b/tests/test_rest_protocol_errors.py index ac30c4c..a915a24 100644 --- a/tests/test_rest_protocol_errors.py +++ b/tests/test_rest_protocol_errors.py @@ -96,6 +96,24 @@ async def test_empty_close_is_still_reported_as_closed_connection(self): self.assertEqual(error.code, 500) self.assertIn("Server closed connection", error.detail) + async def test_malformed_http11_status_line_keeps_400(self): + for answer in (b"HTTP/1.1 abc OK\r\n\r\n", b"HTTP/1.1 2000 OK\r\n\r\n", b"HTTP/1.0 20 OK\r\n\r\n"): + with self.subTest(answer=answer): + self.answer = answer + error = await self.request_error() + self.assertEqual(error.code, 400) + self.assertTrue(error.detail.startswith("HTTP error: "), error.detail) + + @unittest.skipUnless(C_PARSER, "needs aiohttp's C HTTP parser") + async def test_frame_type_byte_alone_is_not_http2(self): + # type byte 0x04 (SETTINGS) at offset 3, but a non-zero stream id or a bad length: not an HTTP/2 frame + for answer in (bytes.fromhex("000006040000000001") + b"abcdef", bytes.fromhex("000005040000000000") + b"abcde"): + with self.subTest(answer=answer): + self.answer = answer + error = await self.request_error() + self.assertEqual(error.code, -2) + self.assertNotIn("(got HTTP/2)", error.detail) + async def test_http_error_status_is_unchanged(self): self.answer = b"HTTP/1.1 400 Bad Request\r\ncontent-length: 8\r\nconnection: close\r\n\r\nbad body" error = await self.request_error() From c5b27211c6878805b997907cf358bd982728eba9 Mon Sep 17 00:00:00 2001 From: Dv2Corn <320380254+Dv2Corn@users.noreply.github.com> Date: Sun, 8 Nov 2026 18:12:04 +1000 Subject: [PATCH 3/4] fix(rest): label HTTP/3 status lines, classify chunked sync errors too An HTTP/3 status line is reported as HTTP/3, not HTTP/2, and only a whole version token counts (HTTP/2, HTTP/2.0, HTTP/3), so a line such as HTTP/200 falls through to the generic description. sync_users_chunked logs and returns the same protocol error text as the other requests when the answer has no HTTP/1.x status line; other failures keep str(e) and rejected stays unset, so retries are unchanged. Tests: HTTP/3 label, HTTP/200 prefix, GOAWAY with a non-zero stream id or a length under 8, the quoted bytes for frames that are not HTTP/2, and the chunked sync detail. --- PasarGuardNodeBridge/rest.py | 15 +++++++++++---- tests/test_rest_protocol_errors.py | 28 +++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/PasarGuardNodeBridge/rest.py b/PasarGuardNodeBridge/rest.py index 4375265..f3aaeea 100644 --- a/PasarGuardNodeBridge/rest.py +++ b/PasarGuardNodeBridge/rest.py @@ -21,6 +21,8 @@ # aiohttp's C parser quotes the bytes it could not parse as a Python bytes literal _QUOTED_BYTES = re.compile(r"b'(?:[^'\\\n]|\\.)*'|b\"(?:[^\"\\\n]|\\.)*\"") +# An HTTP/2 or HTTP/3 status line: the whole version token, so HTTP/200 is not read as HTTP/2 +_HTTP2_OR_3_STATUS = re.compile(rb"HTTP/([23])(?:\.0)?(?:\s|$)") def _is_http2_control_frame(data: bytes) -> bool: @@ -50,8 +52,10 @@ def _describe_non_http11_answer(error: aiohttp.ClientResponseError) -> str | Non if received.startswith(b"HTTP/1."): return None # a malformed HTTP/1.x status line keeps the usual 400 mapping - if received.startswith((b"HTTP/2", b"HTTP/3", b"PRI * HTTP/2.0")) or _is_http2_control_frame(received): - got = "HTTP/2" # a status line, the client preface, or a SETTINGS/GOAWAY frame + if version := _HTTP2_OR_3_STATUS.match(received): + got = f"HTTP/{version[1].decode()}" + elif received.startswith(b"PRI * HTTP/2.0") or _is_http2_control_frame(received): + got = "HTTP/2" # the client preface or a SETTINGS/GOAWAY frame elif received[:1] in (b"\x15", b"\x16") and received[1:2] == b"\x03": got = "TLS data" elif received: @@ -431,8 +435,11 @@ async def _iter_chunks(): return [] except Exception as e: error_type = type(e).__name__ + error_text = str(e) + if isinstance(e, aiohttp.ClientResponseError) and (protocol := _describe_non_http11_answer(e)): + error_text = f"Protocol error: {protocol}" self.logger.warning( - f"[{self.name}] Chunked REST sync failed for {len(users)} user(s) | Error: {error_type} - {e!s}" + f"[{self.name}] Chunked REST sync failed for {len(users)} user(s) | Error: {error_type} - {error_text}" ) # The node answers 500 with its backend's error when it refused the batch. It answers # "backend not initialized" or "backend is not started" (also 500) or 503 when no core @@ -443,7 +450,7 @@ async def _iter_chunks(): and e.response.status_code == 500 and detail not in ("backend not initialized", "backend is not started") ) - return FailedUsers(users, rejected=rejected, detail=detail if rejected else str(e)) + return FailedUsers(users, rejected=rejected, detail=detail if rejected else error_text) async def list_routing_rules(self, timeout: int | None = None) -> service.RoutingRulesResponse | None: timeout = timeout or self._default_timeout diff --git a/tests/test_rest_protocol_errors.py b/tests/test_rest_protocol_errors.py index a915a24..475683f 100644 --- a/tests/test_rest_protocol_errors.py +++ b/tests/test_rest_protocol_errors.py @@ -78,6 +78,17 @@ async def test_http2_status_line_is_reported_as_protocol_error(self): self.assertEqual(error.code, -2) self.assertIn("(got HTTP/2)", error.detail) + async def test_http3_status_line_is_labelled_http3(self): + self.answer = b"HTTP/3 200\r\ncontent-length: 0\r\n\r\n" + error = await self.request_error() + self.assertEqual(error.code, -2) + self.assertIn("(got HTTP/3)", error.detail) + + async def test_version_prefix_alone_is_not_http2(self): + self.answer = b"HTTP/200 OK\r\ncontent-length: 0\r\n\r\n" + error = await self.request_error() + self.assertNotIn("(got HTTP/2)", error.detail) + @unittest.skipUnless(C_PARSER, "needs aiohttp's C HTTP parser") async def test_tls_answer_is_reported_as_protocol_error(self): self.answer = TLS_RECORD @@ -106,13 +117,18 @@ async def test_malformed_http11_status_line_keeps_400(self): @unittest.skipUnless(C_PARSER, "needs aiohttp's C HTTP parser") async def test_frame_type_byte_alone_is_not_http2(self): - # type byte 0x04 (SETTINGS) at offset 3, but a non-zero stream id or a bad length: not an HTTP/2 frame - for answer in (bytes.fromhex("000006040000000001") + b"abcdef", bytes.fromhex("000005040000000000") + b"abcde"): + # a SETTINGS (0x04) or GOAWAY (0x07) type byte at offset 3, but a non-zero stream id or a bad length + for answer in ( + bytes.fromhex("000006040000000001") + b"abcdef", + bytes.fromhex("000005040000000000") + b"abcde", + bytes.fromhex("000008070000000001") + b"abcdefgh", + bytes.fromhex("000004070000000000") + b"abcd", + ): with self.subTest(answer=answer): self.answer = answer error = await self.request_error() self.assertEqual(error.code, -2) - self.assertNotIn("(got HTTP/2)", error.detail) + self.assertIn(f"(got {answer!r})", error.detail) async def test_http_error_status_is_unchanged(self): self.answer = b"HTTP/1.1 400 Bad Request\r\ncontent-length: 8\r\nconnection: close\r\n\r\nbad body" @@ -120,6 +136,12 @@ async def test_http_error_status_is_unchanged(self): self.assertEqual(error.code, 400) self.assertEqual(error.detail, "HTTP error: bad body") + async def test_chunked_sync_reports_protocol_error(self): + self.answer = b"HTTP/2 200\r\ncontent-length: 0\r\n\r\n" + failed = await self.node.sync_users_chunked([], timeout=5) + self.assertFalse(failed.rejected) + self.assertIn("Protocol error: Node did not answer with HTTP/1.1 (got HTTP/2)", failed.detail) + async def test_log_stream_open_reports_protocol_error(self): self.answer = b"HTTP/2 200\r\ncontent-type: text/plain\r\n\r\n" with self.assertRaises(NodeAPIError) as caught: From 8aa8e58a318b5ad5da17bb1c132593bf729041c7 Mon Sep 17 00:00:00 2001 From: Dv2Corn <320380254+Dv2Corn@users.noreply.github.com> Date: Sun, 8 Nov 2026 18:24:42 +1000 Subject: [PATCH 4/4] fix(rest): call a PRI line HTTP/2 only when it is the exact preface line A status line that starts with "PRI * HTTP/2.0" but carries more on the same line is now quoted instead of labelled HTTP/2. Both aiohttp parsers keep only the first line of what they could not parse, so the preface is matched on that line exactly. Tests: the preface line with junk is quoted, the full preface is HTTP/2, the HTTP/200 case asserts code -2 and the quoted line, and the chunked sync test sends three users in two chunks and checks all are returned. --- PasarGuardNodeBridge/rest.py | 3 ++- tests/test_rest_protocol_errors.py | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/PasarGuardNodeBridge/rest.py b/PasarGuardNodeBridge/rest.py index f3aaeea..83b604a 100644 --- a/PasarGuardNodeBridge/rest.py +++ b/PasarGuardNodeBridge/rest.py @@ -54,7 +54,8 @@ def _describe_non_http11_answer(error: aiohttp.ClientResponseError) -> str | Non return None # a malformed HTTP/1.x status line keeps the usual 400 mapping if version := _HTTP2_OR_3_STATUS.match(received): got = f"HTTP/{version[1].decode()}" - elif received.startswith(b"PRI * HTTP/2.0") or _is_http2_control_frame(received): + elif received.rstrip(b"\r\n") == b"PRI * HTTP/2.0" or _is_http2_control_frame(received): + # both parsers keep only the first line of the client preface, so it must match exactly got = "HTTP/2" # the client preface or a SETTINGS/GOAWAY frame elif received[:1] in (b"\x15", b"\x16") and received[1:2] == b"\x03": got = "TLS data" diff --git a/tests/test_rest_protocol_errors.py b/tests/test_rest_protocol_errors.py index 475683f..ada4f53 100644 --- a/tests/test_rest_protocol_errors.py +++ b/tests/test_rest_protocol_errors.py @@ -9,6 +9,7 @@ from PasarGuardNodeBridge import NodeAPIError from PasarGuardNodeBridge.aiohttp_compat import LazyClientSession, make_timeout +from PasarGuardNodeBridge.common import service_pb2 as service from PasarGuardNodeBridge.rest import Node as RestNode from PasarGuardNodeBridge.storage import InMemoryUserSyncStore @@ -87,7 +88,20 @@ async def test_http3_status_line_is_labelled_http3(self): async def test_version_prefix_alone_is_not_http2(self): self.answer = b"HTTP/200 OK\r\ncontent-length: 0\r\n\r\n" error = await self.request_error() - self.assertNotIn("(got HTTP/2)", error.detail) + self.assertEqual(error.code, -2) + self.assertIn("did not answer with HTTP/1.1 (got b'HTTP/200 OK')", error.detail) + + async def test_client_preface_line_with_junk_is_quoted(self): + self.answer = b"PRI * HTTP/2.0 junk\r\n\r\n" + error = await self.request_error() + self.assertEqual(error.code, -2) + self.assertIn("(got b'PRI * HTTP/2.0 junk')", error.detail) + + async def test_client_preface_is_http2(self): + self.answer = b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" + error = await self.request_error() + self.assertEqual(error.code, -2) + self.assertIn("(got HTTP/2)", error.detail) @unittest.skipUnless(C_PARSER, "needs aiohttp's C HTTP parser") async def test_tls_answer_is_reported_as_protocol_error(self): @@ -138,7 +152,9 @@ async def test_http_error_status_is_unchanged(self): async def test_chunked_sync_reports_protocol_error(self): self.answer = b"HTTP/2 200\r\ncontent-length: 0\r\n\r\n" - failed = await self.node.sync_users_chunked([], timeout=5) + users = [service.User(email=f"user-{index}") for index in range(3)] + failed = await self.node.sync_users_chunked(users, chunk_size=2, timeout=5) + self.assertEqual(list(failed), users) self.assertFalse(failed.rejected) self.assertIn("Protocol error: Node did not answer with HTTP/1.1 (got HTTP/2)", failed.detail)