Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4790b3c
feat(sdk/go): add Go SDK foundation, types, and sandbox client (A)
rhuss Jul 14, 2026
a7f6efd
fix(sdk/go): address review feedback on PR #2271
rhuss Jul 15, 2026
6813547
fix(sdk/go): address principal engineer review findings
rhuss Jul 15, 2026
ffbb954
refactor(sdk/go): migrate mise config to centralized task include
rhuss Jul 17, 2026
356494c
refactor(sdk/go): remove UPSTREAM_VERSION standalone repo artifact
rhuss Jul 17, 2026
96f2fe3
refactor(sdk/go): switch proto generation from protoc to buf
rhuss Jul 21, 2026
e8bce72
test(sdk/go): add proto-converter field coverage detection
rhuss Jul 21, 2026
6cdec96
fix(sdk/go): bump Go to 1.26 and fix errcheck lint violations
rhuss Jul 29, 2026
f37ac97
feat(sdk/go): add ObjectMeta fields (annotations, workspace, deletion…
rhuss Jul 29, 2026
08fbde4
chore(sdk/go): regenerate proto bindings after rebase
rhuss Aug 3, 2026
f887bc8
feat(sdk/go): add workspace scoping to all RPC interfaces
rhuss Aug 3, 2026
542d68e
chore(sdk/go): remove coverage.out from tracking
rhuss Aug 3, 2026
7a4550c
fix(sdk/go): address review feedback from mrunalp
rhuss Aug 4, 2026
9935e0f
fix(sdk/go): address remaining review items
rhuss Aug 4, 2026
847c0a4
fix(sdk/go): pin goimports version and update lockfile
rhuss Aug 4, 2026
2166ab0
fix(sdk/go): TLS.Insecure means skip-verify, not plaintext
rhuss Aug 4, 2026
9307f76
feat(sdk/go): add missing policy proto fields
rhuss Aug 4, 2026
18bde6a
fix(sdk/go): enforce coverage test and extend to policy messages
rhuss Aug 4, 2026
c8c65fb
ci(sdk/go): add Go SDK job to branch-checks workflow
rhuss Aug 4, 2026
69a2bc1
fix(sdk/go): address should-fix review items
rhuss Aug 4, 2026
8d3d7e9
ci(sdk/go): add go:format:check to CI pipeline
rhuss Aug 4, 2026
efb78b4
chore(sdk/go): remove Makefile in favor of mise tasks
rhuss Aug 5, 2026
77e65c5
feat(sdk/go): sync proto bindings and add credential handle support
rhuss Aug 5, 2026
939ec51
fix(sdk/go): reject plaintext auth leak and fix watch error handling
rhuss Aug 5, 2026
5aeb1d6
fix(sdk/go): address review findings from multi-agent code review
rhuss Aug 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(sdk/go): reject plaintext auth leak and fix watch error handling
Reject http:// addresses when the auth provider requires transport
security instead of silently stripping the requirement. Remove the
insecureAuthWrapper that overrode RequireTransportSecurity.

Fix watch stream error handling: use blocking send for terminal
errors so they are never silently dropped when the channel is full,
and wrap mid-stream errors with converter.FromGRPCError so SDK error
helpers like IsUnavailable work on watch Event.Err.

Signed-off-by: Roland Huß <[email protected]>
  • Loading branch information
rhuss committed Aug 5, 2026
commit 939ec51441b4e97234586ab827dba434dd448b0d
17 changes: 2 additions & 15 deletions sdk/go/openshell/v1/internal/grpc/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package grpc

import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
Expand Down Expand Up @@ -52,8 +51,8 @@ func NewConnection(address string, tlsCfg *TLSParams, auth credentials.PerRPCCre
}

if auth != nil {
if usePlaintext {
auth = &insecureAuthWrapper{base: auth}
if usePlaintext && auth.RequireTransportSecurity() {
return nil, fmt.Errorf("grpc connect: auth provider requires transport security but address uses plaintext (http://)")
}
opts = append(opts, grpc.WithPerRPCCredentials(auth))
}
Expand Down Expand Up @@ -95,15 +94,3 @@ func buildTLSCredentials(cfg *TLSParams) (credentials.TransportCredentials, erro

return credentials.NewTLS(tlsConfig), nil
}

type insecureAuthWrapper struct {
base credentials.PerRPCCredentials
}

func (w *insecureAuthWrapper) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
return w.base.GetRequestMetadata(ctx, uri...)
}

func (w *insecureAuthWrapper) RequireTransportSecurity() bool {
return false
}
19 changes: 14 additions & 5 deletions sdk/go/openshell/v1/internal/grpc/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ func TestNewConnectionInsecureTLSConfig(t *testing.T) {
defer func() { _ = conn.Close() }()
}

func TestNewConnectionHTTPWithTokenAuth(t *testing.T) {
func TestNewConnectionHTTPWithSecureAuthRejects(t *testing.T) {
auth := &testTokenAuth{token: "dev-token", requireSecurity: true}
_, err := NewConnection("http://127.0.0.1:1", nil, auth)
if err == nil {
t.Fatal("expected error when using http:// with auth that requires transport security")
}
}

func TestNewConnectionHTTPWithInsecureAuth(t *testing.T) {
lis, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatalf("listen: %v", err)
Expand All @@ -71,22 +79,23 @@ func TestNewConnectionHTTPWithTokenAuth(t *testing.T) {
go func() { _ = srv.Serve(lis) }()
defer srv.Stop()

auth := &testTokenAuth{token: "dev-token"}
auth := &testTokenAuth{token: "dev-token", requireSecurity: false}
conn, err := NewConnection("http://"+lis.Addr().String(), nil, auth)
if err != nil {
t.Fatalf("NewConnection with http:// + token auth failed: %v", err)
t.Fatalf("NewConnection with http:// + insecure auth failed: %v", err)
}
defer func() { _ = conn.Close() }()
}

type testTokenAuth struct {
token string
token string
requireSecurity bool
}

func (a *testTokenAuth) GetRequestMetadata(_ context.Context, _ ...string) (map[string]string, error) {
return map[string]string{"authorization": "Bearer " + a.token}, nil
}

func (a *testTokenAuth) RequireTransportSecurity() bool {
return true
return a.requireSecurity
}
12 changes: 4 additions & 8 deletions sdk/go/openshell/v1/sandbox_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,10 @@ func (s *sandboxClient) Watch(ctx context.Context, workspace, name string, opts
var recvErr error
ev, recvErr = stream.Recv()
if recvErr != nil {
select {
case <-w.done:
default:
if recvErr != io.EOF {
select {
case ch <- Event[*Sandbox]{Type: EventError, Err: recvErr}:
default:
}
if recvErr != io.EOF {
select {
case ch <- Event[*Sandbox]{Type: EventError, Err: converter.FromGRPCError(recvErr)}:
case <-w.done:
}
}
return
Expand Down
61 changes: 47 additions & 14 deletions sdk/go/openshell/v1/sandbox_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ const bufSize = 1024 * 1024

type mockSandboxServer struct {
pb.UnimplementedOpenShellServer
mu sync.Mutex
sandboxes map[string]*pb.Sandbox
providers map[string][]*dm.Provider
createErr error
getErr error
listErr error
deleteErr error
attachErr error
detachErr error
listProvErr error
watchEvents []*pb.SandboxStreamEvent
watchErr error
watchKeepOpen chan struct{} // if non-nil, WatchSandbox blocks after sending events until closed
watchRequest *pb.WatchSandboxRequest // recorded request
mu sync.Mutex
sandboxes map[string]*pb.Sandbox
providers map[string][]*dm.Provider
createErr error
getErr error
listErr error
deleteErr error
attachErr error
detachErr error
listProvErr error
watchEvents []*pb.SandboxStreamEvent
watchErr error
watchPostEventsErr error
watchKeepOpen chan struct{} // if non-nil, WatchSandbox blocks after sending events until closed
watchRequest *pb.WatchSandboxRequest // recorded request

// GetLogs fields
getLogsResp *pb.GetSandboxLogsResponse
Expand Down Expand Up @@ -176,6 +177,9 @@ func (s *mockSandboxServer) WatchSandbox(req *pb.WatchSandboxRequest, stream grp
return err
}
}
if s.watchPostEventsErr != nil {
return s.watchPostEventsErr
}
// If watchKeepOpen is set, block until it is closed (simulates long-running stream)
if keepOpen != nil {
<-keepOpen
Expand Down Expand Up @@ -688,6 +692,35 @@ func TestSandboxWatch_RPCError(t *testing.T) {
assert.True(t, IsUnavailable(err))
}

func TestSandboxWatch_MidStreamErrorDeliveredAsStatusError(t *testing.T) {
mock := newMockSandboxServer()
mock.sandboxes["sb-1"] = &pb.Sandbox{
Metadata: &dm.ObjectMeta{Id: "id-1", Name: "sb-1"},
Status: &pb.SandboxStatus{Phase: pb.SandboxPhase_SANDBOX_PHASE_PROVISIONING},
}
mock.watchEvents = []*pb.SandboxStreamEvent{
{Payload: &pb.SandboxStreamEvent_Sandbox{Sandbox: &pb.Sandbox{
Metadata: &dm.ObjectMeta{Name: "sb-1", Id: "id-1"},
Status: &pb.SandboxStatus{Phase: pb.SandboxPhase_SANDBOX_PHASE_PROVISIONING},
}}},
}
mock.watchPostEventsErr = status.Error(codes.Unavailable, "connection lost")
client, cleanup := setupSandboxTest(t, mock)
defer cleanup()

w, err := client.Watch(context.Background(), "default", "sb-1")
require.NoError(t, err)
defer w.Stop()

ev1 := <-w.ResultChan()
assert.Equal(t, EventAdded, ev1.Type)

ev2 := <-w.ResultChan()
assert.Equal(t, EventError, ev2.Type)
require.Error(t, ev2.Err)
assert.True(t, IsUnavailable(ev2.Err), "mid-stream error should be converted to StatusError")
}

// --- T016: Watch name-to-ID resolution verification tests ---

func TestSandboxWatch_ResolvesNameToID(t *testing.T) {
Expand Down
Loading