Fix AI review

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-02-01 21:56:17 +01:00
parent 3d4b215b8f
commit e42e6407df
6 changed files with 29 additions and 11 deletions

View File

@@ -240,7 +240,7 @@ func (c *Client) DeactivateUser(ctx context.Context, userID string) error {
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
respBody, _ := io.ReadAll(resp.Body)
return fmt.Errorf("SCIM API error: status %d, body: %s", resp.StatusCode, string(respBody))
}

View File

@@ -34,7 +34,21 @@ func (r *BridgeRunner) calculateBackoff(consecutiveFailures int) time.Duration {
return r.cfg.Interval
}
backoff := r.cfg.Interval * time.Duration(1<<consecutiveFailures)
// Cap the shift exponent to prevent integer overflow from the shift itself.
// Bit 63 is the sign bit, so shifting by 63+ produces negative or zero values.
const maxShift = 62
shiftAmount := consecutiveFailures
if shiftAmount > maxShift {
shiftAmount = maxShift
}
backoff := r.cfg.Interval * time.Duration(1<<shiftAmount)
// Detect multiplication overflow: if result is non-positive or less than the
// base interval, overflow occurred. Return MaxBackoff in this case.
if backoff <= 0 || backoff < r.cfg.Interval {
return r.cfg.MaxBackoff
}
if backoff > r.cfg.MaxBackoff {
return r.cfg.MaxBackoff