Skip to content

Conversation

@Stexxe
Copy link
Contributor

@Stexxe Stexxe commented Jan 26, 2026

@Stexxe Stexxe requested a review from bjhham January 26, 2026 10:02
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Walkthrough

HttpSend max-send calculation now derives maxSendCount from a per-request MaxRetries attribute when larger than the plugin default (with Int.MAX_VALUE guard); DefaultSender uses maxSendCount. Two tests added to verify interactions between maxRetries and maxSendCount.

Changes

Cohort / File(s) Summary
Core Logic Adjustments
ktor-client/ktor-client-core/common/src/io/ktor/client/plugins/HttpSend.kt
Reworked maxSendCount derivation to read MaxRetriesPerRequestAttributeKey when greater than plugin default, incrementing by 1 unless equal to Int.MAX_VALUE; switched DefaultSender initialization to use maxSendCount instead of maxRetries.
Test Coverage
ktor-client/ktor-client-tests/common/test/io/ktor/client/tests/HttpRequestRetryTest.kt
Added testMaxSendCountGreaterThanMaxRetries() and testMaxSendCountEqualToMaxRetries() to verify behavior for per-request max-retries vs plugin maxSendCount, including redirect and counter scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • bjhham
  • marychatte
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides only a link to the issue without following the required template structure (Subsystem, Motivation, Solution sections are missing). Complete the description by adding Subsystem, Motivation, and Solution sections following the repository template to clearly explain the problem and approach.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: addressing SendCountExceedException when max retries is less than max send count, which aligns with the code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@ktor-client/ktor-client-tests/common/test/io/ktor/client/tests/HttpRequestRetryTest.kt`:
- Around line 551-573: Rename the test function
testMaxSendCountGreaterThanMaxRetries to follow the DescribeWhatIsBeingTested
pattern (for example maxSendCountGreaterThanMaxRetriesAllowsRedirect) while
keeping the `@Test` annotation and the same body; update any references if the
test name is used elsewhere (e.g., test discovery or logging) so the test still
runs and clearly describes the behavior being verified in
HttpRequestRetryTest.kt.

Comment on lines +551 to +573
@Test
fun testMaxSendCountGreaterThanMaxRetries() = testWithEngine(MockEngine) {
config {
engine {
addHandler { request ->
if (request.url.toString().endsWith("/ok")) {
respondOk()
} else {
respondRedirect("/ok")
}
}
}

install(HttpRequestRetry) {
retryOnServerErrors(maxRetries = 0)
delayMillis { 0L }
}
}

test { client ->
assertEquals(HttpStatusCode.OK, client.get("/").status)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Rename test to follow required naming pattern.

Please use the DescribeWhatIsBeingTested format (per test guidelines). As per coding guidelines, consider renaming to something like maxSendCountGreaterThanMaxRetriesAllowsRedirect.

🔧 Suggested rename
-    fun testMaxSendCountGreaterThanMaxRetries() = testWithEngine(MockEngine) {
+    fun maxSendCountGreaterThanMaxRetriesAllowsRedirect() = testWithEngine(MockEngine) {
🤖 Prompt for AI Agents
In
`@ktor-client/ktor-client-tests/common/test/io/ktor/client/tests/HttpRequestRetryTest.kt`
around lines 551 - 573, Rename the test function
testMaxSendCountGreaterThanMaxRetries to follow the DescribeWhatIsBeingTested
pattern (for example maxSendCountGreaterThanMaxRetriesAllowsRedirect) while
keeping the `@Test` annotation and the same body; update any references if the
test name is used elsewhere (e.g., test discovery or logging) so the test still
runs and clearly describes the behavior being verified in
HttpRequestRetryTest.kt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants