Repository navigation
fix(arrow/cdata, arrow/flight): fix handling of colons in values and fix potential panics - #761
Merged
Merged
Conversation
Use strings.Cut, both as an optimization, and to prevent values containing a colon (e.g. "tsu:+01:00") from being mis-interpreted. This patch also removes some intermediate variables, and redundant handling of "defaulttz", which assigned an empty string if the value was empty. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Rewrite the code with strings.Cut and strings.SplitSeq to reduce
allocations, and to fix a potential panic.
Before this patch, the code would panic if a colon was missing;
CGO_ENABLED=1 go test -v -tags test -run TestUnionSchemaErrors ./arrow/cdata/
--- FAIL: TestUnionSchemaErrors (0.00s)
--- FAIL: TestUnionSchemaErrors/+us (0.00s)
panic: runtime error: index out of range [1] with length 1 [recovered, repanicked]
goroutine 9 [running]:
testing.tRunner.func1.2({0x7fc7c0, 0x4000026ab0})
/usr/local/go/src/testing/testing.go:1872 +0x190
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:1875 +0x31c
panic({0x7fc7c0?, 0x4000026ab0?})
/usr/local/go/src/runtime/panic.go:783 +0x120
github.com/apache/arrow-go/v18/arrow/cdata.importSchema(0x40001c36d0)
/foo/arrow/cdata/cdata.go:306 +0x1520
github.com/apache/arrow-go/v18/arrow/cdata.ImportCArrowField(...)
/foo/arrow/cdata/interface.go:43
github.com/apache/arrow-go/v18/arrow/cdata.TestUnionSchemaErrors.func1(0x40000e0a80)
/foo/arrow/cdata/cdata_test.go:188 +0xb0
testing.tRunner(0x40000e0a80, 0x400020c060)
/usr/local/go/src/testing/testing.go:1934 +0xc8
created by testing.(*T).Run in goroutine 8
/usr/local/go/src/testing/testing.go:1997 +0x364
FAIL github.com/apache/arrow-go/v18/arrow/cdata 0.007s
FAIL
With this patch applied, the code handles the invalid value gracefully;
CGO_ENABLED=1 go test -v -tags test -run TestUnionSchemaErrors ./arrow/cdata/
=== RUN TestUnionSchemaErrors
=== RUN TestUnionSchemaErrors/+us
=== RUN TestUnionSchemaErrors/+ud
--- PASS: TestUnionSchemaErrors (0.00s)
--- PASS: TestUnionSchemaErrors/+us (0.00s)
--- PASS: TestUnionSchemaErrors/+ud (0.00s)
PASS
ok github.com/apache/arrow-go/v18/arrow/cdata 0.003s
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Rewrite the code with strings.Cut for readability and ensue missing credentials
in Basic/Bearer authorization headers return Unauthenticated instead of
panicking.
Before this patch, the code could panic;
go test -run TestBasicAuthMissingCredential ./arrow/flight/
panic: runtime error: index out of range [1] with length 1
goroutine 7 [running]:
github.com/apache/arrow-go/v18/arrow/flight_test.TestBasicAuthMissingCredential.CreateServerBasicAuthMiddleware.createServerBearerTokenStreamInterceptor.func3({0x8d8240, 0x40002134a0}, {0xa73e68, 0x40000e2000}, 0x40000100c0, 0x96b628)
/foo/arrow/flight/server_auth.go:188 +0x49c
....
With this patch applied, the code handles the invalid header gracefully;
go test -run TestBasicAuthMissingCredential ./arrow/flight/
ok github.com/apache/arrow-go/v18/arrow/flight 0.010s
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Contributor
Author
|
Heh; yeah went a bit down the rabbit hole; this module is an indirect dependency in some of our code and was bringing in some transitive dependencies, so I thought; let's see what I can do there, but my branch grew a bit large, so opening smaller PRs from it to keep it reviewable. More PRs probably incoming, but keep a good eye; I'm not very familiar with this repository 🥹 |
Member
|
I appreciate it! I'll definitely keep an eye out to review them as they come in 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(arrow/cdata): importSchema: handle colons in values
Use strings.Cut, both as an optimization, and to prevent values containing
a colon (e.g. "tsu:+01:00") from being mis-interpreted. This patch also
removes some intermediate variables, and redundant handling of "defaulttz",
which assigned an empty string if the value was empty.
fix(arrow/cdata): importSchema: fix potential panic and optimize
Rewrite the code with strings.Cut and strings.SplitSeq to reduce
allocations, and to fix a potential panic.
Before this patch, the code would panic if a colon was missing;
With this patch applied, the code handles the invalid value gracefully;
fix(arrow/flight): avoid panic on malformed authorization header
Rewrite the code with strings.Cut for readability and ensue missing credentials
in Basic/Bearer authorization headers return Unauthenticated instead of
panicking.
Before this patch, the code could panic;
With this patch applied, the code handles the invalid header gracefully;
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?