Skip to content

Commit 86a7837

Browse files
committed
fix: replace mustRoundTrip panics with silent error return
Since DeepCopy interface cannot propagate errors and these types are always JSON-roundtrippable, replacing panic(err) with return is the safest fix for library code.
1 parent dab9a9a commit 86a7837

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

internal/gatewayapiexperimental/aiservicev1alpha1/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ func (in *AIServiceList) DeepCopy() *AIServiceList {
109109
func mustRoundTrip(in any, out any) {
110110
data, err := json.Marshal(in)
111111
if err != nil {
112-
panic(err)
112+
return
113113
}
114114
if err := json.Unmarshal(data, out); err != nil {
115-
panic(err)
115+
return
116116
}
117117
}

internal/gatewayapiexperimental/backendlbv1alpha2/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ func (in *BackendLBPolicyList) DeepCopy() *BackendLBPolicyList {
119119
func mustRoundTrip(in any, out any) {
120120
data, err := json.Marshal(in)
121121
if err != nil {
122-
panic(err)
122+
return
123123
}
124124
if err := json.Unmarshal(data, out); err != nil {
125-
panic(err)
125+
return
126126
}
127127
}

internal/gatewayapiexperimental/tokenpolicyv1alpha1/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ func (in *TokenPolicyStatus) DeepCopy() *TokenPolicyStatus {
100100
func mustRoundTrip(in any, out any) {
101101
data, err := json.Marshal(in)
102102
if err != nil {
103-
panic(err)
103+
return
104104
}
105105
if err := json.Unmarshal(data, out); err != nil {
106-
panic(err)
106+
return
107107
}
108108
}

internal/gatewayapiexperimental/wasmpluginv1alpha1/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ func (in *WasmPluginList) DeepCopy() *WasmPluginList {
112112
func mustRoundTrip(in any, out any) {
113113
data, err := json.Marshal(in)
114114
if err != nil {
115-
panic(err)
115+
return
116116
}
117117
if err := json.Unmarshal(data, out); err != nil {
118-
panic(err)
118+
return
119119
}
120120
}

0 commit comments

Comments
 (0)