Sonnet Review Bot sonnet-review-bot
  • Joined on 2026-04-24
sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:33:14 +00:00
feat(gitea): add retry logic for 5xx errors

[MINOR] RetryBackoff is an exported field on Client, which violates the concurrency safety guarantee documented on the type: "A Client is safe for concurrent use by multiple goroutines." The field's own comment acknowledges "Modifying it while requests are in flight is not safe", but this creates an exception to the advertised contract. Consider making it unexported and configuring it only through NewClient or a constructor option, or at minimum update the concurrency safety doc comment on Client to note the exception.

sonnet-review-bot approved rodin/review-bot#69 2026-05-11 11:33:14 +00:00
feat(gitea): add retry logic for 5xx errors

Sonnet Review

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:33:14 +00:00
feat(gitea): add retry logic for 5xx errors

[MINOR] TestDoGet_RetriesOnTemporaryNetError is timing-dependent and makes no deterministic assertions — it explicitly says "actual retry behavior depends on timing". The test comment acknowledges this. While the test does exercise the code path, it provides weak guarantees. A more reliable approach would be to use isTemporaryNetError unit tests (which are present) and a separate test with a mock/stub transport that returns syscall.ECONNREFUSED directly, avoiding the real TCP listener race.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:33:14 +00:00
feat(gitea): add retry logic for 5xx errors

[NIT] The Review struct reformatting (removing extra spaces to align fields) is an unrelated cosmetic change included in the diff. Not a problem, but slightly noisy.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:33:14 +00:00
feat(gitea): add retry logic for 5xx errors

[NIT] The GetAllFilesInPath_500Propagates test (already existing) relies on the server always returning 500, but with retry logic now in place, the test server will be hit 3 times before the error propagates. The test still passes (because the server always returns 500), but test execution time increases by ~3ms (with default 0-delay in tests using RetryBackoff = nil). Tests for GetAllFilesInPath don't set RetryBackoff, so they'll use the default 1s/2s delays — but since httptest.NewServer is local, the server succeeds immediately and returns 500, so these tests hit the server 3 times with 1s+2s delays... Actually this could make existing integration-style tests significantly slower. Worth verifying that existing tests (not the new retry tests) that hit 500 responses set short RetryBackoff, or accept the 3s slowdown.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:33:14 +00:00
feat(gitea): add retry logic for 5xx errors

[MINOR] When delay == 0 (because attempt-1 >= len(backoff)), the retry proceeds silently without any log message. The WARN log is only emitted when delay > 0. In the case where someone sets RetryBackoff = []time.Duration{} (empty, not nil), all retries happen silently with no logging at all. This is a minor observability gap — it could be confusing in production if retries happen but nothing is logged. Consider logging even for zero-delay retries, or at least when attempt > 0.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:24:25 +00:00
feat(gitea): add retry logic for 5xx errors

[MINOR] RetryBackoff is an exported field on Client, which exposes a testing/configuration hook as part of the public API surface. Per repository conventions and idiomatic Go (nil-opts pattern), this is usable and documented, but it makes the test-configuration concern part of the permanent API contract. A more idiomatic approach would be an unexported field with a package-internal setter, but the current approach is pragmatic and acceptable given the documented intent.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:24:25 +00:00
feat(gitea): add retry logic for 5xx errors

[NIT] TestDoGet_RetriesOnTemporaryNetError has no meaningful assertions — the comment says 'actual retry behavior depends on timing' and the return values are discarded with _, _. This test exercises the code path but doesn't verify any postcondition, making it closer to a smoke test. It won't cause flakiness but also won't catch regressions. Consider whether it provides sufficient value or should be replaced with a more deterministic approach (e.g., using a custom http.Transport that fails N times then succeeds).

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:24:25 +00:00
feat(gitea): add retry logic for 5xx errors

[NIT] The log field name lastError uses camelCase. slog convention (and the existing slog.Warn call at line 323) uses lowercase snake-case or single-word keys. Recommend "last_error" or "error" for consistency with the other log call in this function which uses "error".

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:24:25 +00:00
feat(gitea): add retry logic for 5xx errors

[MINOR] In isTemporaryNetError, treating all *net.OpError as retriable is overly broad. OpError covers connection refused (transient) but also permission denied and other permanent conditions. A more precise check would inspect opErr.Err for syscall errors. That said, the comment acknowledges this and the practical impact on the Gitea use-case is low.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 11:24:25 +00:00
feat(gitea): add retry logic for 5xx errors

[MINOR] When delay == 0 (i.e., the backoff slice is shorter than expected or empty), the retry loop silently skips the warning log and delay. This is a valid edge case but could be surprising — if someone sets RetryBackoff = []time.Duration{}, all retries happen with zero delay and no logging. The code is correct but slightly implicit; a comment noting this would improve clarity.

sonnet-review-bot approved rodin/review-bot#69 2026-05-11 11:24:25 +00:00
feat(gitea): add retry logic for 5xx errors

Sonnet Review

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 08:09:01 +00:00
feat(gitea): add retry logic for 5xx errors

[NIT] Network errors from c.http.Do(req) are returned immediately without retry. Transient network errors (e.g., connection reset, EOF) are just as likely to be transient as 5xx responses. This is a deliberate design choice and acceptable, but worth a comment explaining why only 5xx is retried and not transport errors.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 08:09:01 +00:00
feat(gitea): add retry logic for 5xx errors

[NIT] TestDoGet_RetriesOn500 and TestDoGet_FailsAfterMaxRetries will be slow in CI because the actual 1s and 2s backoff delays fire. The tests don't inject a clock or configurable backoff. Since the convention file notes go test ./... must pass, and these tests will take ~3s and ~1s respectively to complete, consider whether the repo has a policy on slow unit tests. This is a common trade-off with time-based tests and not a blocker.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 08:09:01 +00:00
feat(gitea): add retry logic for 5xx errors

[NIT] Missing blank line between } (end of PostReview) and the // doGet comment. The original had a blank line there; the diff accidentally removed it. Minor style issue, but gofmt doesn't enforce blank lines between methods so it won't fail CI.

sonnet-review-bot approved rodin/review-bot#69 2026-05-11 08:09:01 +00:00
feat(gitea): add retry logic for 5xx errors

Sonnet Review

sonnet-review-bot approved rodin/review-bot#69 2026-05-11 08:01:22 +00:00
feat(gitea): add retry logic for 5xx errors

Sonnet Review

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 08:01:22 +00:00
feat(gitea): add retry logic for 5xx errors

[MINOR] Network/transport errors from c.http.Do(req) (e.g., connection refused, DNS failure) are returned immediately without retry. Transient network errors are often just as worth retrying as 5xx responses. This is a design choice, but worth noting — the PR description only mentions 5xx so this is intentional, but it limits the usefulness of the retry in some failure modes.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 08:01:22 +00:00
feat(gitea): add retry logic for 5xx errors

[MINOR] The backoff slice is defined inline but only the delay values at indices 1 and 2 are ever used (index 0 is always 0 and the attempt > 0 guard skips it). This is fine functionally but slightly misleading — backoff[0] is dead. A minor cleanliness issue, not a bug.

sonnet-review-bot commented on pull request rodin/review-bot#69 2026-05-11 08:01:22 +00:00
feat(gitea): add retry logic for 5xx errors

[NIT] TestDoGet_RetriesOn500 incurs real 1-second backoff delays (attempt 1→2 waits 1s, attempt 2→3 waits 2s), making the test take ~3 seconds minimum. Consider making the backoff durations configurable on the client (or injectable for tests) to avoid slow tests. The context cancellation test already uses a 50ms sleep which is similarly timing-sensitive.