Skip to content

Commit 9107058

Browse files
committed
fix: use GENERAL error code for provider initialization failures
- Change from PROVIDER_FATAL to GENERAL for initialization exceptions - Aligns with cross-SDK behavior for generic initialization errors - Update tests to expect GENERAL error code Signed-off-by: Sameeran Kunche <sameeran.kunche@datadoghq.com>
1 parent e222491 commit 9107058

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/open_feature/sdk/configuration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ def init_provider(provider, context, raise_on_error: false)
145145
dispatch_provider_event(provider, ProviderEvent::PROVIDER_READY)
146146
rescue => e
147147
dispatch_provider_event(provider, ProviderEvent::PROVIDER_ERROR,
148-
error_code: Provider::ErrorCode::PROVIDER_FATAL,
148+
error_code: Provider::ErrorCode::GENERAL,
149149
message: e.message)
150150

151151
if raise_on_error
152152
# Re-raise as ProviderInitializationError for synchronous callers
153153
raise ProviderInitializationError.new(
154154
"Provider #{provider.class.name} initialization failed: #{e.message}",
155155
provider:,
156-
error_code: Provider::ErrorCode::PROVIDER_FATAL,
156+
error_code: Provider::ErrorCode::GENERAL,
157157
original_error: e
158158
)
159159
end

spec/open_feature/sdk/configuration_async_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def shutdown
201201

202202
# Wait for initialization
203203
sleep(0.1)
204-
expect(configuration.send(:provider_state, provider)).to eq(OpenFeature::SDK::ProviderState::FATAL)
204+
expect(configuration.send(:provider_state, provider)).to eq(OpenFeature::SDK::ProviderState::ERROR)
205205
end
206206
end
207207

spec/open_feature/sdk/configuration_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
expect(error.message).to include(error_message)
129129
expect(error.provider).to be(provider)
130130
expect(error.original_error).to be_a(StandardError) # Synchronous init preserves original exception
131-
expect(error.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::PROVIDER_FATAL)
131+
expect(error.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::GENERAL)
132132
end
133133
end
134134

spec/open_feature/sdk_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
expect do
4646
OpenFeature::SDK.set_provider_and_wait(provider)
4747
end.to raise_error(OpenFeature::SDK::ProviderInitializationError, /Provider initialization failed/) do |error|
48-
expect(error.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::PROVIDER_FATAL)
48+
expect(error.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::GENERAL)
4949
end
5050

5151
# Clean up

0 commit comments

Comments
 (0)