thaJeztah opened a new pull request, #761:
URL: https://github.com/apache/arrow-go/pull/761
### 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;
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
### 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;
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
### Rationale for this change
### What changes are included in this PR?
### Are these changes tested?
### Are there any user-facing changes?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]