Skip to content

Commit 0bc6a58

Browse files
authored
Remove error returned from grpc.ProblemDetailsToPB as it's not used (#8607)
Fixes #8581
1 parent 02abf8d commit 0bc6a58

6 files changed

Lines changed: 15 additions & 38 deletions

File tree

grpc/pb-marshalling.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ var ErrInvalidParameters = CodedError(codes.InvalidArgument, "RPC parameter was
2828
// This file defines functions to translate between the protobuf types and the
2929
// code types.
3030

31-
func ProblemDetailsToPB(prob *probs.ProblemDetails) (*corepb.ProblemDetails, error) {
31+
func ProblemDetailsToPB(prob *probs.ProblemDetails) *corepb.ProblemDetails {
3232
if prob == nil {
3333
// nil problemDetails is valid
34-
return nil, nil
34+
return nil
3535
}
3636
return &corepb.ProblemDetails{
3737
ProblemType: string(prob.Type),
3838
Detail: prob.Detail,
3939
HttpStatus: int32(prob.HTTPStatus), //nolint: gosec // HTTP status codes are guaranteed to be small, no risk of overflow.
40-
}, nil
40+
}
4141
}
4242

4343
func PBToProblemDetails(in *corepb.ProblemDetails) (*probs.ProblemDetails, error) {
@@ -59,12 +59,10 @@ func PBToProblemDetails(in *corepb.ProblemDetails) (*probs.ProblemDetails, error
5959
}
6060

6161
func ChallengeToPB(challenge core.Challenge) (*corepb.Challenge, error) {
62-
prob, err := ProblemDetailsToPB(challenge.Error)
63-
if err != nil {
64-
return nil, err
65-
}
62+
prob := ProblemDetailsToPB(challenge.Error)
6663
recordAry := make([]*corepb.ValidationRecord, len(challenge.ValidationRecord))
6764
for i, v := range challenge.ValidationRecord {
65+
var err error
6866
recordAry[i], err = ValidationRecordToPB(v)
6967
if err != nil {
7068
return nil, err
@@ -196,10 +194,7 @@ func ValidationResultToPB(records []core.ValidationRecord, prob *probs.ProblemDe
196194
return nil, err
197195
}
198196
}
199-
marshalledProb, err := ProblemDetailsToPB(prob)
200-
if err != nil {
201-
return nil, err
202-
}
197+
marshalledProb := ProblemDetailsToPB(prob)
203198
return &vapb.ValidationResult{
204199
Records: recordAry,
205200
Problem: marshalledProb,
@@ -228,10 +223,7 @@ func pbToValidationResult(in *vapb.ValidationResult) ([]core.ValidationRecord, *
228223
}
229224

230225
func CAAResultToPB(prob *probs.ProblemDetails, perspective, rir string) (*vapb.IsCAAValidResponse, error) {
231-
marshalledProb, err := ProblemDetailsToPB(prob)
232-
if err != nil {
233-
return nil, err
234-
}
226+
marshalledProb := ProblemDetailsToPB(prob)
235227
return &vapb.IsCAAValidResponse{
236228
Problem: marshalledProb,
237229
Perspective: perspective,

grpc/pb-marshalling_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ import (
1919
const JWK1JSON = `{"kty":"RSA","n":"vuc785P8lBj3fUxyZchF_uZw6WtbxcorqgTyq-qapF5lrO1U82Tp93rpXlmctj6fyFHBVVB5aXnUHJ7LZeVPod7Wnfl8p5OyhlHQHC8BnzdzCqCMKmWZNX5DtETDId0qzU7dPzh0LP0idt5buU7L9QNaabChw3nnaL47iu_1Di5Wp264p2TwACeedv2hfRDjDlJmaQXuS8Rtv9GnRWyC9JBu7XmGvGDziumnJH7Hyzh3VNu-kSPQD3vuAFgMZS6uUzOztCkT0fpOalZI6hqxtWLvXUMj-crXrn-Maavz8qRhpAyp5kcYk3jiHGgQIi7QSK2JIdRJ8APyX9HlmTN5AQ","e":"AQAB"}`
2020

2121
func TestProblemDetails(t *testing.T) {
22-
pb, err := ProblemDetailsToPB(nil)
23-
test.AssertNotEquals(t, err, "problemDetailToPB failed")
22+
pb := ProblemDetailsToPB(nil)
2423
test.Assert(t, pb == nil, "Returned corepb.ProblemDetails is not nil")
2524

2625
prob := &probs.ProblemDetails{Type: probs.TLSProblem, Detail: "asd", HTTPStatus: 200}
27-
pb, err = ProblemDetailsToPB(prob)
28-
test.AssertNotError(t, err, "problemDetailToPB failed")
26+
pb = ProblemDetailsToPB(prob)
2927
test.Assert(t, pb != nil, "return corepb.ProblemDetails is nill")
3028
test.AssertDeepEquals(t, pb.ProblemType, string(prob.Type))
3129
test.AssertEquals(t, pb.Detail, prob.Detail)

ra/ra.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -903,19 +903,11 @@ func (ra *RegistrationAuthorityImpl) failOrder(
903903
defer cancel()
904904

905905
// Convert the problem to a protobuf problem for the *corepb.Order field
906-
pbProb, err := bgrpc.ProblemDetailsToPB(prob)
907-
if err != nil {
908-
ra.log.AuditErr("Converting order problem to PB", err, map[string]any{
909-
"requester": order.RegistrationID,
910-
"order": order.Id,
911-
"prob": prob.String(),
912-
})
913-
return
914-
}
906+
pbProb := bgrpc.ProblemDetailsToPB(prob)
915907

916908
// Assign the protobuf problem to the field and save it via the SA
917909
order.Error = pbProb
918-
_, err = ra.SA.SetOrderError(ctx, &sapb.SetOrderErrorRequest{
910+
_, err := ra.SA.SetOrderError(ctx, &sapb.SetOrderErrorRequest{
919911
Id: order.Id,
920912
Error: order.Error,
921913
})
@@ -1559,8 +1551,7 @@ func (ra *RegistrationAuthorityImpl) PerformValidation(
15591551
},
15601552
)
15611553
if err != nil {
1562-
// ProblemDetailsToPB never returns an error.
1563-
prob, _ = bgrpc.ProblemDetailsToPB(probs.ServerInternal("Could not communicate with VA"))
1554+
prob = bgrpc.ProblemDetailsToPB(probs.ServerInternal("Could not communicate with VA"))
15641555
ra.log.Errf("Failed to communicate with VA: %s", err)
15651556
}
15661557

sa/model.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,7 @@ func populateAttemptedFields(am authzModel, challenge *corepb.Challenge) error {
733733
am.ValidationError,
734734
err)
735735
}
736-
challenge.Error, err = grpc.ProblemDetailsToPB(&prob)
737-
if err != nil {
738-
return err
739-
}
736+
challenge.Error = grpc.ProblemDetailsToPB(&prob)
740737
} else {
741738
// If the error is empty the challenge must be valid.
742739
challenge.Status = string(core.StatusValid)

sa/model_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ func TestAuthzModel(t *testing.T) {
118118
validationErr := probs.Connection("weewoo")
119119

120120
authzPB.Challenges[0].Status = string(core.StatusInvalid)
121-
authzPB.Challenges[0].Error, err = grpc.ProblemDetailsToPB(validationErr)
122-
test.AssertNotError(t, err, "grpc.ProblemDetailsToPB failed")
121+
authzPB.Challenges[0].Error = grpc.ProblemDetailsToPB(validationErr)
123122
model, err = authzPBToModel(authzPB)
124123
test.AssertNotError(t, err, "authzPBToModel failed")
125124

sa/sa_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,7 @@ func TestFinalizeAuthorization2(t *testing.T) {
21582158
test.AssertEquals(t, dbVer.Challenges[0].Validated.AsTime(), attemptedAt)
21592159

21602160
authzID = createPendingAuthorization(t, sa, reg.Id, identifier.NewDNS("aaa"), fc.Now().Add(time.Hour))
2161-
prob, _ := bgrpc.ProblemDetailsToPB(probs.Connection("it went bad captain"))
2161+
prob := bgrpc.ProblemDetailsToPB(probs.Connection("it went bad captain"))
21622162

21632163
_, err = sa.FinalizeAuthorization2(context.Background(), &sapb.FinalizeAuthorizationRequest{
21642164
Id: authzID,

0 commit comments

Comments
 (0)