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 calls to fmt Errorf with no interpolation #187

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions ssas/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ func ListGroups(ctx context.Context) (list GroupList, err error) {
func UpdateGroup(ctx context.Context, id string, gd GroupData) (Group, error) {
g, err := GetGroupByID(ctx, id)
if err != nil {
errString := fmt.Sprintf("record not found for id=%s", id)
err := fmt.Errorf(errString)
err := fmt.Errorf("record not found for id=%s", id)
return Group{}, err
}
gd.GroupID = g.Data.GroupID
Expand Down
10 changes: 5 additions & 5 deletions ssas/service/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ func ChooseSigningKey(signingKeyPath, signingKey string) (*rsa.PrivateKey, error
if err != nil {
msg := fmt.Sprintf("bad signing key; path %s; %v", signingKeyPath, err)
ssas.Logger.Error(msg)
error = fmt.Errorf(msg)
error = errors.New(msg)
}
key = sk
} else if signingKey != "" && signingKeyPath == "" {
sk, err := ssas.ReadPrivateKey([]byte(signingKey))
if err != nil {
msg := fmt.Sprintf("bad inline signing key; %v", err)
ssas.Logger.Error(msg)
error = fmt.Errorf(msg)
error = errors.New(msg)
}
key = sk
} else if signingKey == "" && signingKeyPath == "" {
msg := "inline key and path are both empty strings"
ssas.Logger.Error(msg)
error = fmt.Errorf(msg)
error = errors.New(msg)
} else {
msg := "inline key or path must be set, but not both"
ssas.Logger.Error(msg)
error = fmt.Errorf(msg)
error = errors.New(msg)
}

return key, error
Expand Down Expand Up @@ -481,7 +481,7 @@ func (s *Server) CheckRequiredClaims(claims *CommonClaims, requiredTokenType str
}

if requiredTokenType != claims.TokenType {
return fmt.Errorf(fmt.Sprintf("wrong token type: %s; required type: %s", claims.TokenType, requiredTokenType))
return fmt.Errorf("wrong token type: %s; required type: %s", claims.TokenType, requiredTokenType)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion ssas/service/tokenblacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (t *Blacklist) BlacklistToken(ctx context.Context, tokenID string, blacklis
entryDate := time.Now()
expirationDate := entryDate.Add(blacklistExpiration)
if _, err := ssas.CreateBlacklistEntry(ctx, tokenID, entryDate, expirationDate); err != nil {
return fmt.Errorf(fmt.Sprintf("unable to blacklist token id %s: %s", tokenID, err.Error()))
return fmt.Errorf("unable to blacklist token id %s: %s", tokenID, err.Error())
}

// Add to cache only after token is blacklisted in database
Expand Down
2 changes: 1 addition & 1 deletion ssas/systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (system *System) RevokeSecret(ctx context.Context, systemID string) error {

err = system.deactivateSecrets(ctx)
if err != nil {
return fmt.Errorf("unable to revoke credentials for clientID " + system.ClientID)
return fmt.Errorf("unable to revoke credentials for clientID %s", system.ClientID)
}
return nil
}
Expand Down
Loading