Cloud migrations: add more context to errors (#93814)

* Cloud migrations: add more context to errors

* calls to assert.ErrorIs was passing arguments in the wrong order
This commit is contained in:
Bruno
2024-09-30 09:57:25 -03:00
committed by GitHub
parent ddbf0a05af
commit 6f92fd64ce
3 changed files with 7 additions and 6 deletions
@@ -432,16 +432,16 @@ func (ss *sqlStore) encryptToken(ctx context.Context, cm *cloudmigration.CloudMi
func (ss *sqlStore) decryptToken(ctx context.Context, cm *cloudmigration.CloudMigrationSession) error {
if cm == nil {
return cloudmigration.ErrMigrationNotFound
return fmt.Errorf("unable to decypt token because migration session was not found: %w", cloudmigration.ErrMigrationNotFound)
}
if len(cm.AuthToken) == 0 {
return cloudmigration.ErrTokenNotFound
return fmt.Errorf("unable to decrypt token because token is empty: %w", cloudmigration.ErrTokenNotFound)
}
decoded, err := base64.StdEncoding.DecodeString(cm.AuthToken)
if err != nil {
return fmt.Errorf("token could not be decoded")
return fmt.Errorf("unable to base64 decode token: %w", err)
}
t, err := ss.secretsService.Decrypt(ctx, decoded)