roachpb: Prohibit access to NoopRequest.Header()#11919
roachpb: Prohibit access to NoopRequest.Header()#11919bdarnell merged 3 commits intocockroachdb:masterfrom
Conversation
|
Reviewed 7 of 7 files at r1, 4 of 4 files at r2, 2 of 2 files at r3. pkg/kv/batch_test.go, line 102 at r3 (raw file):
looks like something got truncated here, and there's a spurious empty line below pkg/roachpb/gen_batch.go, line 54 at r1 (raw file):
"the following exceptions:" so the next person doesn't have to edit this again Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks broke. Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks broke. pkg/kv/batch_test.go, line 102 at r3 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Removed this line and the blank one pkg/roachpb/gen_batch.go, line 54 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. Comments from Reviewable |
|
Reviewed 1 of 7 files at r4, 4 of 4 files at r5, 2 of 2 files at r6. Comments from Reviewable |
Restore the header fields to deprecated requests and responses instead of embedding a NoopRequest (partially reverting cockroachdb#9362). NoopRequests do not have keys, but never appear alone, ensuring that the batch as a whole has at least one request with keys. Deprecated requests, however, can appear alone and therefore must have keys to allow other invariants to be validated.
Guard all (tested) accesses to Request.Header with explicit checks for NoopRequest.
The roachpb.Method type is sometimes a convenient shorthand for referring to different kinds of roachpb.Requests, but where it matters we always use type switches. The Method of a request has occasionally diverged from its type, leading to problems as in cockroachdb#11919. Additionally, as a part of cleaning up cockroachdb#10084, I'm about to introduce a new type storage.Command which makes roachpb.Method feel redundant.
Add explicit type checks to guard against inappropriate access.
Fixes #11195
This change is