Skip to content

Commit dd5ccfb

Browse files
committed
Restore typed http2.StreamError check; add x/net license metadata
The previous fixup dropped the typed errors.As(err, &http2.StreamError{}) check because importing golang.org/x/net/http2 promoted golang.org/x/net from indirect to direct in go.mod and tripped the SPDX license test. Per CLAUDE.md, we should not branch on err.Error() content when a typed sentinel is available, so restore the typed check and pay the license metadata tax instead: - Add // BSD-3-Clause suffix on the direct require in go.mod. - Add a matching entry to NOTICE under the BSD (3-clause) section. Update the test that previously claimed to cover the wrapped/typed form (but actually used errors.New) to wrap a real http2.StreamError. Co-authored-by: Isaac
1 parent f4da3c3 commit dd5ccfb

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

NOTICE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ golang.org/x/mod - https://github.com/golang/mod
103103
Copyright 2009 The Go Authors.
104104
License - https://github.com/golang/mod/blob/master/LICENSE
105105

106+
golang.org/x/net - https://github.com/golang/net
107+
Copyright 2009 The Go Authors.
108+
License - https://github.com/golang/net/blob/master/LICENSE
109+
106110
golang.org/x/oauth2 - https://github.com/golang/oauth2
107111
Copyright 2009 The Go Authors.
108112
License - https://github.com/golang/oauth2/blob/master/LICENSE

experimental/ssh/internal/client/releases.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/databricks/cli/libs/filer"
1616
"github.com/databricks/cli/libs/log"
1717
"github.com/databricks/databricks-sdk-go"
18+
"golang.org/x/net/http2"
1819
)
1920

2021
type releaseProvider func(ctx context.Context, architecture, version, releasesDir string) (io.ReadCloser, error)
@@ -83,9 +84,14 @@ func uploadReleases(ctx context.Context, workspaceFiler filer.Filer, getRelease
8384

8485
// isStreamResetError reports whether err looks like an HTTP/2 stream reset from
8586
// the server, which typically means an edge proxy or the workspace-files import
86-
// endpoint rejected the request body (e.g. body-size limit). Matches both the
87-
// raw http2.StreamError.Error() format and wrapped variants.
87+
// endpoint rejected the request body (e.g. body-size limit). The string fallback
88+
// catches cases where a transport layer re-formats the http2 error before it
89+
// reaches us, losing the typed value but preserving the message shape.
8890
func isStreamResetError(err error) bool {
91+
var se http2.StreamError
92+
if errors.As(err, &se) {
93+
return true
94+
}
8995
msg := err.Error()
9096
return strings.Contains(msg, "stream error") && strings.Contains(msg, "stream ID")
9197
}

experimental/ssh/internal/client/releases_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77

88
"github.com/stretchr/testify/assert"
9+
"golang.org/x/net/http2"
910
)
1011

1112
func TestIsStreamResetError(t *testing.T) {
@@ -15,13 +16,13 @@ func TestIsStreamResetError(t *testing.T) {
1516
want bool
1617
}{
1718
{
18-
name: "raw http2 stream error string",
19-
err: errors.New("stream error: stream ID 15; NO_ERROR"),
19+
name: "typed http2.StreamError wrapped",
20+
err: fmt.Errorf(`Post "https://example/api/2.0/workspace-files/import-file/...": %w`, http2.StreamError{StreamID: 15, Code: http2.ErrCodeNo}),
2021
want: true,
2122
},
2223
{
23-
name: "wrapped peer-reset error (Go HTTP/2 client format)",
24-
err: fmt.Errorf(`Post "https://example/api/2.0/workspace-files/import-file/...": %w`, errors.New("stream error: stream ID 15; NO_ERROR; received from peer")),
24+
name: "stringified stream error",
25+
err: errors.New("stream error: stream ID 15; NO_ERROR; received from peer"),
2526
want: true,
2627
},
2728
{

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ require (
3737
go.yaml.in/yaml/v3 v3.0.4 // MIT AND Apache-2.0
3838
golang.org/x/crypto v0.49.0 // BSD-3-Clause
3939
golang.org/x/mod v0.34.0 // BSD-3-Clause
40+
golang.org/x/net v0.51.0 // BSD-3-Clause
4041
golang.org/x/oauth2 v0.36.0 // BSD-3-Clause
4142
golang.org/x/sync v0.20.0 // BSD-3-Clause
4243
golang.org/x/sys v0.43.0 // BSD-3-Clause
@@ -97,7 +98,6 @@ require (
9798
go.opentelemetry.io/otel/metric v1.43.0 // indirect
9899
go.opentelemetry.io/otel/trace v1.43.0 // indirect
99100
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
100-
golang.org/x/net v0.51.0 // indirect
101101
golang.org/x/time v0.14.0 // indirect
102102
google.golang.org/api v0.265.0 // indirect
103103
google.golang.org/genproto/googleapis/rpc v0.0.0-20260203192932-546029d2fa20 // indirect

0 commit comments

Comments
 (0)