fix: properly handle rows.Err() (#4261)
* fix (auth): properly handle rows.Err() * fix (auth/ldap): properly handle rows.Err() * fix (auth/oidc): properly handle rows.Err() * fix (auth/password): properly handle rows.Err() * fix (authtoken): properly handle rows.Err() * fix (credential): properly handle rows.Err() * fix (credential/static): properly handle rows.Err() * fix (credential/vault): properly handle rows.Err() * fix (db): properly handle rows.Err() * fix (db/schema): properly handle rows.Err() * fix (db/migrations): properly handle rows.Err() * fix (host): properly handle rows.Err() * fix (host/plugin): properly handle rows.Err() * fix (host/static): properly handle rows.Err() * fix (iam): properly handle rows.Err() * fix (kms): properly handle rows.Err() * fix (oplog): properly handle rows.Err() * fix (pagination/purge): properly handle rows.Err() * fix (plugin): properly handle rows.Err() * fix (job/scheduler): properly handle rows.Err() * fix (server): properly handle rows.Err() * fix (session): properly handle rows.Err() * fix (target): properly handle rows.Err()
This commit is contained in:
59 files changed
+252
-2
No files matched your search
@@ -88,6 +88,7 @@ select count(*) from test_auth_method where public_id = @public_id
|
||||
err := rw.ScanRows(ctx, rows, &count)
|
||||
require.NoError(err)
|
||||
}
|
||||
assert.NoError(rows.Err())
|
||||
assert.Equal(1, count.Count)
|
||||
|
||||
count.Count = 0
|
||||
@@ -98,6 +99,7 @@ select count(*) from test_auth_method where public_id = @public_id
|
||||
err := rw.ScanRows(ctx, rows, &count)
|
||||
require.NoError(err)
|
||||
}
|
||||
assert.NoError(rows.Err())
|
||||
assert.Equal(1, count.Count)
|
||||
}
|
||||
|
||||
@@ -170,6 +172,7 @@ values
|
||||
err := rw.ScanRows(ctx, rows, &count)
|
||||
require.NoError(err)
|
||||
}
|
||||
assert.NoError(rows.Err())
|
||||
assert.Equal(1, count.Count)
|
||||
|
||||
count.Count = 0
|
||||
@@ -180,5 +183,6 @@ values
|
||||
err := rw.ScanRows(ctx, rows, &count)
|
||||
require.NoError(err)
|
||||
}
|
||||
assert.NoError(rows.Err())
|
||||
assert.Equal(1, count.Count)
|
||||
}
|
||||
@@ -371,5 +371,8 @@ func (r *Repository) estimatedAccountCount(ctx context.Context) (int, error) {
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap account counts"))
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap account counts"))
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
@@ -381,5 +381,8 @@ func (r *Repository) estimatedManagedGroupCount(ctx context.Context) (int, error
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap managed group counts"))
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap managed group counts"))
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
@@ -400,5 +400,8 @@ func (r *Repository) estimatedAccountCount(ctx context.Context) (int, error) {
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap account counts"))
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap account counts"))
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
@@ -184,6 +184,9 @@ func (r *Repository) upsertAccount(ctx context.Context, am *AuthMethod, IdTokenC
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg("unable to scan rows for account"))
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg("unable to get next rows for account"))
|
||||
}
|
||||
if rowCnt > 1 {
|
||||
return errors.New(ctx, errors.MultipleRecords, op, fmt.Sprintf("expected 1 row but got: %d", rowCnt))
|
||||
}
|
||||
|
||||
@@ -368,5 +368,8 @@ func (r *Repository) estimatedManagedGroupCount(ctx context.Context) (int, error
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap managed group counts"))
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap managed group counts"))
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
@@ -442,5 +442,8 @@ func (r *Repository) estimatedAccountCount(ctx context.Context) (int, error) {
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap account counts"))
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query ldap account counts"))
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
@@ -159,7 +159,9 @@ func (r *Repository) currentConfigForAccount(ctx context.Context, accountId stri
|
||||
}
|
||||
confs = append(confs, conf)
|
||||
}
|
||||
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
var cc currentConfig
|
||||
switch {
|
||||
case len(confs) == 0:
|
||||
|
||||
@@ -229,6 +229,9 @@ func (r *Repository) authenticate(ctx context.Context, scopeId, authMethodId, lo
|
||||
}
|
||||
accts = append(accts, aa)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
var acct authAccount
|
||||
switch {
|
||||
|
||||
@@ -135,6 +135,9 @@ func (amr *AuthMethodRepository) EstimatedCount(ctx context.Context) (int, error
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query total auth methods"))
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return 0, errors.Wrap(ctx, err, op, errors.WithMsg("failed to query total auth methods"))
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
@@ -154,6 +157,9 @@ func (amr *AuthMethodRepository) ListDeletedIds(ctx context.Context, since time.
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
transactionTimestamp, err = r.Now(ctx)
|
||||
return err
|
||||
}); err != nil {
|
||||
@@ -179,7 +185,9 @@ func (amr *AuthMethodRepository) queryAuthMethods(ctx context.Context, query str
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := rows.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, am := range foundAuthMethods {
|
||||
authmethod, err := am.toAuthMethod(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user