diff --git a/src/OpenFeatureClient.php b/src/OpenFeatureClient.php index 4181a60..0f90aab 100644 --- a/src/OpenFeatureClient.php +++ b/src/OpenFeatureClient.php @@ -372,9 +372,10 @@ private function evaluateFlag( ), ); - $error = $err instanceof ThrowableWithResolutionError ? $err->getResolutionError() : new ResolutionError(ErrorCode::GENERAL()); + $error = $err instanceof ThrowableWithResolutionError ? $err->getResolutionError() : new ResolutionError(ErrorCode::GENERAL(), $err->getMessage()); $details = (new EvaluationDetailsBuilder()) + ->withFlagKey($flagKey) ->withValue($defaultValue) ->withReason(Reason::ERROR) ->withError($error) diff --git a/tests/unit/OpenFeatureClientTest.php b/tests/unit/OpenFeatureClientTest.php index 1b5cd46..55627a8 100644 --- a/tests/unit/OpenFeatureClientTest.php +++ b/tests/unit/OpenFeatureClientTest.php @@ -499,6 +499,7 @@ public function testClientEvaluationDetailsAbnormalExecutionHasErrorCodeField(): $resolutionError = $actualDetails->getError(); $this->assertNotNull($resolutionError); $this->assertEquals($expectedErrorCode, $resolutionError->getResolutionErrorCode()); + $this->assertEquals('flagKey', $actualDetails->getFlagKey()); } /** @@ -563,9 +564,14 @@ public function testClientShouldLogInformativeErrorDuringAbnormalExecution(): vo $client = new OpenFeatureClient($api, 'test-name', 'test-version'); $client->setLogger($mockLogger); - $value = $client->getBooleanValue('flagKey', false); + $details = $client->getBooleanDetails('flagKey', false); - $this->assertEquals($value, false); + $this->assertEquals(false, $details->getValue()); + $this->assertEquals('flagKey', $details->getFlagKey()); + + $this->assertInstanceOf(ResolutionError::class, $details->getError()); + $this->assertEquals(ErrorCode::GENERAL(), $details->getError()->getResolutionErrorCode()); + $this->assertEquals('NETWORK_ERROR', $details->getError()->getResolutionErrorMessage()); } /**