Fix Gravity metadata nil session client panic#289
Conversation
📝 WalkthroughWalkthroughThe PR improves resilience of metadata RPC calls by introducing a helper function to select the first non-nil session client and refactoring both ChangesSession client resilience for metadata RPCs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
gravity/control_stream_resilience_test.go (1)
278-320: ⚡ Quick winAdd mirrored regression tests for
GetSandboxMetadata.Line 278+ adds strong coverage for
GetDeploymentMetadata, but the same nil-client selection path inGetSandboxMetadataremains untested. Please add equivalent cases for empty clients, all-nil clients, and later non-nil client selection.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@gravity/control_stream_resilience_test.go` around lines 278 - 320, Add three mirrored tests for GetSandboxMetadata: TestGetSandboxMetadata_NoSessionClientsReturnsError, TestGetSandboxMetadata_AllNilSessionClientsReturnsError, and TestGetSandboxMetadata_UsesLaterNonNilSessionClient. For the first, create g := newResilienceTestClient(t, 0, false) and call g.GetSandboxMetadata(...), assert an error contains "no gRPC session clients available". For the second, create g := newResilienceTestClient(t, 2, true), set g.sessionClients = []pb.GravitySessionServiceClient{nil, nil}, call GetSandboxMetadata and assert an error contains "no usable gRPC session clients available". For the third, create g := newResilienceTestClient(t, 3, true), set a laterClient := &mockSessionClient{sandboxResp: &pb.SandboxMetadataResponse{Success: true}} and g.sessionClients = []pb.GravitySessionServiceClient{nil, laterClient, nil}, call GetSandboxMetadata, assert no error, resp.GetSuccess() is true, and laterClient.sandboxCalls == 1.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@gravity/control_stream_resilience_test.go`:
- Around line 278-320: Add three mirrored tests for GetSandboxMetadata:
TestGetSandboxMetadata_NoSessionClientsReturnsError,
TestGetSandboxMetadata_AllNilSessionClientsReturnsError, and
TestGetSandboxMetadata_UsesLaterNonNilSessionClient. For the first, create g :=
newResilienceTestClient(t, 0, false) and call g.GetSandboxMetadata(...), assert
an error contains "no gRPC session clients available". For the second, create g
:= newResilienceTestClient(t, 2, true), set g.sessionClients =
[]pb.GravitySessionServiceClient{nil, nil}, call GetSandboxMetadata and assert
an error contains "no usable gRPC session clients available". For the third,
create g := newResilienceTestClient(t, 3, true), set a laterClient :=
&mockSessionClient{sandboxResp: &pb.SandboxMetadataResponse{Success: true}} and
g.sessionClients = []pb.GravitySessionServiceClient{nil, laterClient, nil}, call
GetSandboxMetadata, assert no error, resp.GetSuccess() is true, and
laterClient.sandboxCalls == 1.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 75c9e901-ac56-470c-be45-b8d59f461d40
📒 Files selected for processing (3)
go.modgravity/control_stream_resilience_test.gogravity/grpc_client.go
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: Analyze (go)
🔇 Additional comments (3)
gravity/grpc_client.go (1)
7047-7060: LGTM!Also applies to: 7062-7077, 7082-7096
gravity/control_stream_resilience_test.go (1)
20-23: LGTM!Also applies to: 27-28, 48-54, 59-65
go.mod (1)
3-3: Updatego.modtogo 1.26.4: valid stable release with security fixes
go 1.26.4is an official stable Go release (June 2, 2026) and is the latest patch version for the 1.26 line; it includes security fixes (including issues incrypto/x509,mime, andnet/textproto).
Summary
Test
Summary by CodeRabbit
Bug Fixes
Tests
Chores