Repository navigation
Require initial non-ACK SETTINGS in HTTP/2 connections - #1457
Conversation
pjfanning
left a comment
There was a problem hiding this comment.
Thanks, the parser change looks right. The check runs on the frame header before unknown frame types are dropped, and it's only cleared after the whole first frame has parsed, so a fragmented SETTINGS payload retries correctly. Failing the stage gives GOAWAY with last-stream-id 0 via errorHandling, which is accurate here since no streams can have been processed. A few points on the tests and docs:
- The ACK case accepts two outcomes. The invalid-preface branch passes on either a PROTOCOL_ERROR GOAWAY or a bare completion, and logs which one it saw with
info. WithInvalidConnectionPrefacegoing throughfailStage→Http2Blueprint.errorHandling, the behaviour is deterministic: aGoAwayFrame(0, PROTOCOL_ERROR)followed by completion. Could the test require exactly that? As written, a regression that drops the GOAWAY would still pass. TheOnErrorbranch's message ("requires provenance review before classification") could also just be a plain failure. - Minor: imports.
Http2FirstSettingsSpecspells outorg.apache.pekkoon every import. Pekko code usually doesimport org.apache.pekkoonce and thenimport pekko.http.... - Minor: the extra constructor.
Http2FrameParsingisprivate[http2]and@InternalApi, so keeping a separate 3-argument constructor next to the new default parameter isn't needed for compatibility. Either one alone would do. - Docs. The two identical "Connection preface" sections in the client and server
http2.mddescribe RFC behaviour users can't configure. I'd drop them.
Motivation: Both endpoints continued ordinary control-frame processing after an initial SETTINGS acknowledgment, contrary to RFC 9113 section 3.4. Modification: Enable connection-only first-frame validation while retaining generic parser behavior and constructor compatibility. Terminate this specific preface error through the existing protocol-error path and retain the focused tests. Omit the duplicated client/server protocol documentation as requested in review. Result: Preserve the existing implementation and tests without repeating protocol requirements in the user documentation. Other review feedback remains pending. Tests: - git diff --check passed for the documentation-only revision. - Runtime and test blobs are identical to e976cdc. - Not run - docs only revision. docs/paradox not run: JAVA_HOME is unset and javac is unavailable; no toolchain changes were made. - Original PR records 29 focused tests and scoped formatting/import, header, MiMa and documentation checks. These historical results were not rerun or independently verified for this revision. References: Refs apache#1457; RFC 9113 section 3.4; documentation review by pjfanning.
e976cdc to
096b413
Compare
Motivation: Require the connection preface contract while preserving generic frame parsing. Address the reviewer-requested test import convention and omit duplicated docs. Modification: Retain the existing connection-only first-frame validation and tests. Use the org.apache.pekko root import followed by pekko-prefixed test imports. Omit duplicated client/server protocol documentation. Result: The test imports follow repository convention without changing test behavior. Constructor compatibility and protocol-policy review points remain unchanged. Tests: - Cached Scalafmt 3.11.5 reports the revised test unchanged. - git diff --check passed; changes from the reviewed head are imports only. - Exact previous head 096b413 has successful Headers, Scalafmt, and Validate and test workflows. - Tests and full compilation were not rerun for this import-only revision; javac is unavailable. No protocol-error scenarios were executed. References: Refs apache#1457; RFC 9113 section 3.4; pjfanning review.
096b413 to
2505857
Compare
Motivation: Require the connection preface contract while preserving generic frame parsing. Address the reviewer-requested test import convention and omit duplicated docs. Modification: Retain the existing connection-only first-frame validation and tests. Use the org.apache.pekko root import followed by pekko-prefixed test imports. Omit duplicated client/server protocol documentation. Result: The test imports follow repository convention without changing test behavior. Constructor compatibility and protocol-policy review points remain unchanged. Tests: - Cached Scalafmt 3.11.5 reports the revised test unchanged. - git diff --check passed; changes from the reviewed head are imports only. - Exact previous head 096b413 has successful Headers, Scalafmt, and Validate and test workflows. - Tests and full compilation were not rerun for this import-only revision; javac is unavailable. No protocol-error scenarios were executed. References: Refs apache#1457; RFC 9113 section 3.4; pjfanning review.
Motivation: The initial SETTINGS ACK case accepted either a PROTOCOL_ERROR GOAWAY or a bare completion, so a regression that dropped the GOAWAY would still pass. The extra three-argument Http2FrameParsing constructor is not needed for this internal class. Modification: Expect exactly GoAwayFrame(0, PROTOCOL_ERROR) followed by completion, and remove the redundant constructor. Result: The test pins the connection error the server and client actually send. Tests: - sbt "http2-tests/testOnly ...Http2FirstSettingsSpec": 10 passed - sbt "http-core/mimaReportBinaryIssues": passed References: Refs apache#1457 review
2505857 to
8911e11
Compare
|
I rebased this onto |
Motivation: The client and server startup tests confirm the initial SETTINGS frame type, but do not check that a non-default concurrent stream limit reaches the peer. Modification: Use different positive limits for the two endpoints in the existing nonempty SETTINGS cases and assert the single advertised value on the decoded first outbound frame. Leave other settings and the remaining scenarios unchanged. Result: The tests catch a missing, duplicated, or defaulted advertisement without opening HTTP/2 request streams or changing production code. Tests: - JDK 17, Scala 2.13.18 and 3.3.9: both exact-name nonempty startup tests passed on each axis using unchanged main production classes. - Scoped scalafmt and git diff --check passed. Full sbt was not run. References: Refs #1457; RFC 9113 section 6.5.2.
Motivation
RFC 9113 section 3.4 requires each peer's connection preface to start with a SETTINGS frame, not a SETTINGS acknowledgment. The client and server previously continued processing ordinary control frames after an initial SETTINGS ACK.
Modification
Http2FrameParsingconstructor (no separate three-argument constructor). No user-facing docs change, since this is standard RFC behaviour that users can't configure.Result
Both endpoints reject an initial SETTINGS ACK rather than acknowledging a subsequent PING. Valid connections still send their own preface without waiting for the peer's preface. Generic parser consumers can continue parsing standalone frames.
Tests
+http-core/mimaReportBinaryIssuespasses on Scala 2.13.18 and 3.3.9.docs/paradoxpasses (existing unrelated duplicate-anchor warnings).git diff --checkpasses. Full suites/aggregate validation and CI were not run; verification used the listed focused scopes.References