Skip to content

Commit

Permalink
fix: webhook on github sponsorship cause crash due to an error or for…
Browse files Browse the repository at this point in the history
…mat (#628)

**Describe the pull request**

We encountered a critical issue where the webhook associated with GitHub
Sponsorships is causing a system crash. The crash occurs due to an
unexpected error in the payload format received from the webhook

**Checklist**

- [x] I have made the modifications or added tests related to my PR
- [x] I have run the tests and linters locally and they pass
- [x] I have added/updated the documentation for my RP

---------

Signed-off-by: Atomys <[email protected]>
  • Loading branch information
42atomys authored Aug 23, 2024
1 parent c2f04cf commit 8ddbbad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion internal/webhooks/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ type githubSponsorshipWebhookPayload struct {
} `json:"tier"`
// The edited event types include the details about the change when
// someone edits a sponsorship to change the privacy.
PrivacyLevel string `json:"privacy_level"`
PrivacyLevel struct {
From string `json:"from"`
} `json:"privacy_level"`
} `json:"changes"`
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/otelgql/otelgql.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package otelgql

import (
"context"
"fmt"
"errors"

"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler/extension"
Expand Down Expand Up @@ -84,7 +84,7 @@ func (a Tracer) InterceptResponse(ctx context.Context, next graphql.ResponseHand
resp := next(ctx)
if resp != nil && len(resp.Errors) > 0 {
span.SetStatus(codes.Error, resp.Errors.Error())
span.RecordError(fmt.Errorf(resp.Errors.Error()))
span.RecordError(errors.New(resp.Errors.Error()))
span.SetAttributes(ResolverErrors(resp.Errors)...)
}

Expand Down Expand Up @@ -115,7 +115,7 @@ func (a Tracer) InterceptField(ctx context.Context, next graphql.Resolver) (inte
errList := graphql.GetFieldErrors(ctx, fc)
if len(errList) != 0 {
span.SetStatus(codes.Error, errList.Error())
span.RecordError(fmt.Errorf(errList.Error()))
span.RecordError(errList)
span.SetAttributes(ResolverErrors(errList)...)
}

Expand Down

0 comments on commit 8ddbbad

Please sign in to comment.