Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic during error returning if Dataset\Query couldn't have found #48

Merged
merged 4 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/server/dekart/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package dekart
import (
"context"
"crypto/sha1"
"fmt"
"time"

"dekart/src/proto"
"dekart/src/server/job"
"dekart/src/server/user"
"fmt"
"time"

"github.com/google/uuid"
"github.com/rs/zerolog/log"
Expand All @@ -32,7 +33,7 @@ func (s Server) CreateQuery(ctx context.Context, req *proto.CreateQueryRequest)
if reportID == nil {
err := fmt.Errorf("dataset not found or permission not granted")
log.Warn().Err(err).Str("dataset_id", req.DatasetId).Send()
return nil, status.Error(codes.NotFound, err.Error())
return nil, status.Error(codes.NotFound, "Dataset not found or permission not granted")
Tsovak marked this conversation as resolved.
Show resolved Hide resolved
}

id := newUUID()
Expand Down Expand Up @@ -220,7 +221,7 @@ func (s Server) RunQuery(ctx context.Context, req *proto.RunQueryRequest) (*prot
if reportID == "" {
err := fmt.Errorf("query not found id:%s", req.QueryId)
log.Warn().Err(err).Send()
return nil, status.Error(codes.NotFound, err.Error())
return nil, status.Error(codes.NotFound, "Query not found")
}

err = s.storeQuerySync(ctx, req.QueryId, req.QueryText, prevQuerySourceId)
Expand Down Expand Up @@ -285,7 +286,7 @@ func (s Server) CancelQuery(ctx context.Context, req *proto.CancelQueryRequest)
}
if reportID == "" {
log.Warn().Str("QueryId", req.QueryId).Msg("Query not found")
return nil, status.Error(codes.NotFound, err.Error())
return nil, status.Errorf(codes.NotFound, "Query not found")
Tsovak marked this conversation as resolved.
Show resolved Hide resolved
}

if ok := s.jobs.Cancel(req.QueryId); !ok {
Expand Down
9 changes: 7 additions & 2 deletions src/server/user/claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,14 @@ func (c ClaimsCheck) GetContext(r *http.Request) context.Context {
return userCtx
}

//GetClaims from the context
// GetClaims from the context
func GetClaims(ctx context.Context) *Claims {
return ctx.Value(contextKey).(*Claims)
value, isExist := ctx.Value(contextKey).(*Claims)
if isExist {
return value
}

return nil
}

func (c ClaimsCheck) getPublicKeyFromAmazon(token *jwt.Token) (interface{}, error) {
Expand Down