PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: open-telemetry/opentelemetry-php (php)

Issue:
PsrTransport maxRetries off by one
The `$maxRetries` parameter of [`PsrTransport::_construct()`](https://github.com/open-telemetry/opentelemetry-php/blob/ff15cc7037cbdb58641785434b61fd1aa9f27085/src/SDK/Common/Export/Http/PsrTransport.php#L58) appears to be off by one - it's being used as "tries" rather than "retries".

This has the effect of going into an infinite loop if you try and disable retries by passing `0` for `$maxRetries`.

I've created a PR, but this would be a small backwards compatibility break.

Pull request:
Fix for maxRetries=0
Fixes #1095

Patch:
diff --git a/src/SDK/Common/Export/Http/PsrTransport.php b/src/SDK/Common/Export/Http/PsrTransport.php
index e84dde38..a53e5b80 100644
--- a/src/SDK/Common/Export/Http/PsrTransport.php
+++ b/src/SDK/Common/Export/Http/PsrTransport.php
@@ -110,7 +110,7 @@ final class PsrTransport implements TransportInterface
                 return new ErrorFuture($e);
             }
 
-            if ($retries + 1 === $this->maxRetries) {
+            if ($retries >= $this->maxRetries) {
                 return new ErrorFuture(new RuntimeException('Export retry limit exceeded', 0, $e));
             }
 


Test patch:
diff --git a/tests/Unit/SDK/Common/Export/Http/PsrTransportTest.php b/tests/Unit/SDK/Common/Export/Http/PsrTransportTest.php
index d7fa907d..adbc97c1 100644
--- a/tests/Unit/SDK/Common/Export/Http/PsrTransportTest.php
+++ b/tests/Unit/SDK/Common/Export/Http/PsrTransportTest.php
@@ -131,7 +131,19 @@ final class PsrTransportTest extends TestCase
     public function test_send_returns_error_if_retry_limit_exceeded(): void
     {
         $this->client->expects($this->once())->method('sendRequest')->willReturn(new Response(500));
-        $transport = $this->factory->create('http://localhost', 'text/plain', [], null, 10., 100, 1);
+        $transport = $this->factory->create('http://localhost', 'text/plain', [], null, 10., 100, 0);
+
+        $response = $transport->send('');
+
+        $this->expectException(Exception::class);
+        $this->expectExceptionMessage('retry limit');
+        $response->await();
+    }
+
+    public function test_send_number_of_retries(): void
+    {
+        $this->client->expects($this->exactly(4))->method('sendRequest')->willReturn(new Response(500));
+        $transport = $this->factory->create('http://localhost', 'text/plain', [], null, 10., 100, 3);
 
         $response = $transport->send('');