Skip to content

Commit

Permalink
backend: Fix nil pointer dereference
Browse files Browse the repository at this point in the history
Don't count on OperationID being set in OperationDocuments.
Implicit async operations will not have this field set. Get
the subscription ID from ExternalID instead.
  • Loading branch information
Matthew Barnes committed Dec 4, 2024
1 parent 353d9e9 commit d76b6ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/operations_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (s *OperationsScanner) pollClusterOperation(ctx context.Context, logger *sl
if err != nil {
var ocmError *ocmerrors.Error
if errors.As(err, &ocmError) && ocmError.Status() == http.StatusNotFound && doc.Request == database.OperationRequestDelete {
err = s.withSubscriptionLock(ctx, logger, doc.OperationID.SubscriptionID, func(ctx context.Context) error {
err = s.withSubscriptionLock(ctx, logger, doc.ExternalID.SubscriptionID, func(ctx context.Context) error {
return s.deleteOperationCompleted(ctx, logger, doc)
})
if err == nil {
Expand All @@ -180,7 +180,7 @@ func (s *OperationsScanner) pollClusterOperation(ctx context.Context, logger *sl
logger.Warn(err.Error())
err = nil
} else {
err = s.withSubscriptionLock(ctx, logger, doc.OperationID.SubscriptionID, func(ctx context.Context) error {
err = s.withSubscriptionLock(ctx, logger, doc.ExternalID.SubscriptionID, func(ctx context.Context) error {
return s.updateOperationStatus(ctx, logger, doc, opStatus, opError)
})
}
Expand Down

0 comments on commit d76b6ac

Please sign in to comment.