Err for grant/revoke when no row affected#113
Conversation
|
Claude finished @MarcusGoldschmidt's task in 1m 1s —— View job
Review: Err for grant/revoke when no row affectedThis PR introduces sentinel errors for zero/multi-row affected cases in provisioning queries and handles the zero-rows case in Issue:
// provisioning.go:75-78
err = s.RunProvisioningQueries(ctx, provisioningConfig.Grant.Queries, provisioningVars, useTx)
if err != nil {
return nil, err // ← ErrQueryAffectedZeroRows not handled
}Per the Grant Idempotency pattern in CLAUDE.md, "already exists" should be treated as success: if errors.Is(err, ErrQueryAffectedZeroRows) {
anno := annotations.Annotations{}
anno.Update(&v2.GrantAlreadyExists{})
return anno, nil
}Minor observation: zero rows may be legitimate in multi-query provisioning
Summary: The sentinel errors and Revoke handling look good. The main gap is the missing |
|
Claude finished @MarcusGoldschmidt's task in 52s —— View job
Review: Err for grant/revoke when no row affectedThe sentinel errors and Revoke handling look good overall. A few items to address: 1.
// provisioning.go:74-78
useTx := !provisioningConfig.Grant.NoTransaction
err = s.RunProvisioningQueries(ctx, provisioningConfig.Grant.Queries, provisioningVars, useTx)
if err != nil {
return nil, err // ← ErrQueryAffectedZeroRows not handled
}Per the Grant Idempotency pattern in CLAUDE.md, "already exists" should return success with an annotation: if errors.Is(err, ErrQueryAffectedZeroRows) {
anno := annotations.Annotations{}
anno.Update(&v2.GrantAlreadyExists{})
return anno, nil
}2. The new 3. Minor: The removal of Summary: The core change (sentinel errors + Revoke annotation) is solid. The main gap remains: |
|
Claude finished @MarcusGoldschmidt's task in 1m 7s —— View job
Review: Err for grant/revoke when no row affected (v3)Good progress — the previous review feedback about 1. Validation query If result, err := executor.QueryContext(ctx, q, qArgs...)
if err != nil {
return fmt.Errorf("failed to execute validation query: %w", err)
}
valid := result.Next()
if err := result.Err(); err != nil {
return fmt.Errorf("failed to read validation query result: %w", err) // ← result not closed
}
err = result.Close()Use result, err := executor.QueryContext(ctx, q, qArgs...)
if err != nil {
return fmt.Errorf("failed to execute validation query: %w", err)
}
defer result.Close()
valid := result.Next()
if err := result.Err(); err != nil {
return fmt.Errorf("failed to read validation query result: %w", err)
}This also lets you remove the explicit 2. Validation query failure returns a generic error — not mapped to a sentinel When a validation query returns no rows (line 366): if !valid {
return fmt.Errorf("validation query returned no rows")
}This is a plain If the intent is that failed validation should be treated the same as zero affected rows (i.e., idempotent "already exists"/"already revoked"), wrap the sentinel: if !valid {
return fmt.Errorf("validation query returned no rows: %w", ErrQueryAffectedZeroRows)
}If validation failure should be a hard error (different from zero rows affected), the current behavior is correct — just be aware that it bypasses the idempotency handling. 3. Minor: As noted in the previous review, neither Summary: The core changes look good. Both |
Description
Useful links: