nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: open-feature/js-sdk
Pull request #680 (2023-11-22 15:49:54)

fix: add Provider Not Ready Error
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
Adds an Error class for the error code Provider Not Ready. To match the other error codes. 


toddbaert: Oh, thanks for finding this @Billlynch . This should indeed be here, see https://openfeature.dev/specification/types#error-code
toddbaert: I'm ready to merge, but could you sign off your commit? (it's a CNCF requirement).

Patch:
diff --git a/packages/shared/src/errors/index.ts b/packages/shared/src/errors/index.ts
index 24952fa6..6a58e0c8 100644
--- a/packages/shared/src/errors/index.ts
+++ b/packages/shared/src/errors/index.ts
@@ -5,3 +5,4 @@ export * from './type-mismatch-error';
 export * from './targeting-key-missing-error';
 export * from './invalid-context-error';
 export * from './open-feature-error-abstract';
+export * from './provider-not-ready-error';
diff --git a/packages/shared/src/errors/provider-not-ready-error.ts b/packages/shared/src/errors/provider-not-ready-error.ts
new file mode 100644
index 00000000..7aeea524
--- /dev/null
+++ b/packages/shared/src/errors/provider-not-ready-error.ts
@@ -0,0 +1,12 @@
+import { OpenFeatureError } from './open-feature-error-abstract';
+import { ErrorCode } from '../evaluation';
+
+export class ProviderNotReadyError extends OpenFeatureError {
+  code: ErrorCode;
+  constructor(message?: string) {
+    super(message);
+    Object.setPrototypeOf(this, ProviderNotReadyError.prototype);
+    this.name = 'ProviderNotReadyError';
+    this.code = ErrorCode.PROVIDER_NOT_READY;
+  }
+}


Test patch:
diff --git a/packages/server/test/errors.spec.ts b/packages/server/test/errors.spec.ts
index b472f521..ae0504e3 100644
--- a/packages/server/test/errors.spec.ts
+++ b/packages/server/test/errors.spec.ts
@@ -4,6 +4,7 @@ import {
   GeneralError,
   InvalidContextError,
   ParseError,
+  ProviderNotReadyError,
   TargetingKeyMissingError,
   TypeMismatchError,
 } from '../src';
@@ -56,4 +57,12 @@ describe('Errors', () => {
     expect(error.name).toBe('InvalidContextError');
     expect(error instanceof InvalidContextError).toBe(true);
   });
+
+  it('ProviderNotReadyError', () => {
+    const error = new ProviderNotReadyError('message');
+    expect(error.message).toBe('message');
+    expect(error.code).toBe(ErrorCode.PROVIDER_NOT_READY);
+    expect(error.name).toBe('ProviderNotReadyError');
+    expect(error instanceof ProviderNotReadyError).toBe(true);
+  });
 });
Repository: open-feature/js-sdk
Pull request #703 (2023-12-01 19:03:00)

feat: ability to get current provider state
This is separate PR for a similar change [here](https://github.com/open-feature/js-sdk/pull/698).

I'm hesitant to spec this at the moment. I'm only implementing it in the client because it seems particularly useful for React.


Patch:
diff --git a/packages/client/src/client/client.ts b/packages/client/src/client/client.ts
index 6bd96b9d..2eec5c8e 100644
--- a/packages/client/src/client/client.ts
+++ b/packages/client/src/client/client.ts
@@ -1,6 +1,10 @@
-import { ClientMetadata, EvaluationLifeCycle, Eventing, ManageLogger } from '@openfeature/core';
+import { ClientMetadata, EvaluationLifeCycle, Eventing, ManageLogger, ProviderStatus } from '@openfeature/core';
 import { Features } from '../evaluation';
 
 export interface Client extends EvaluationLifeCycle<Client>, Features, ManageLogger<Client>, Eventing {
   readonly metadata: ClientMetadata;
-}
+  /**
+   * Returns the status of the associated provider.
+   */
+  readonly providerStatus: ProviderStatus;
+}
\ No newline at end of file
diff --git a/packages/client/src/client/open-feature-client.ts b/packages/client/src/client/open-feature-client.ts
index f159b4a5..f8b0a15f 100644
--- a/packages/client/src/client/open-feature-client.ts
+++ b/packages/client/src/client/open-feature-client.ts
@@ -11,6 +11,7 @@ import {
   Logger,
   OpenFeatureError,
   ProviderEvents,
+  ProviderStatus,
   ResolutionDetails,
   SafeLogger,
   StandardResolutionReasons,
@@ -49,6 +50,10 @@ export class OpenFeatureClient implements Client {
     };
   }
 
+  get providerStatus(): ProviderStatus {
+    return this.providerAccessor()?.status || ProviderStatus.READY;
+  }
+
   addHandler<T extends ProviderEvents>(eventType: T, handler: EventHandler<T>): void {
     this.emitterAccessor().addHandler(eventType, handler);
     const shouldRunNow = statusMatchesEvent(eventType, this._provider.status);


Test patch:
diff --git a/packages/client/test/client.spec.ts b/packages/client/test/client.spec.ts
index 58088d03..73ca224a 100644
--- a/packages/client/test/client.spec.ts
+++ b/packages/client/test/client.spec.ts
@@ -528,5 +528,17 @@ describe('OpenFeatureClient', () => {
       });
     });
   });
+
+  describe('providerStatus', () => {
+    it('should return current provider status', ()=> {
+      OpenFeature.setProvider({ ...MOCK_PROVIDER, status: ProviderStatus.STALE});
+      expect(OpenFeature.getClient().providerStatus).toEqual(ProviderStatus.STALE);
+    });
+
+    it('should return READY if not defined', ()=> {
+      OpenFeature.setProvider(MOCK_PROVIDER);
+      expect(OpenFeature.getClient().providerStatus).toEqual(ProviderStatus.READY);
+    });
+  });
 });
Repository: open-feature/js-sdk
Pull request #844 (2024-03-01 20:36:38)

fix: allow iteration over all event types
This is an addendum to https://github.com/open-feature/js-sdk/pull/816.

Since the `addHandler` overloads for the event types (`ProviderEvents.ConfigurationChanged` and `NotChangeEvents`) are mutually exclusive, it was impossible to iterate over them and pass the same function...

I had to add one more "base" overload that tolerated both. This doesn't reduce any of the nice type safety added in https://github.com/open-feature/js-sdk/pull/816, but allows users to iterate over `ProviderEvents` collections as seen in the new tests.


Patch:
diff --git a/packages/shared/src/events/eventing.ts b/packages/shared/src/events/eventing.ts
index fb489027..753bfebb 100644
--- a/packages/shared/src/events/eventing.ts
+++ b/packages/shared/src/events/eventing.ts
@@ -87,6 +87,10 @@ export interface Eventing<T extends ServerProviderEvents | ClientProviderEvents>
     eventType: T extends ClientProviderEvents ? ClientNotChangeEvents : ServerNotChangeEvents,
     handler: EventHandler<T extends ClientProviderEvents ? ClientNotChangeEvents : ServerNotChangeEvents>,
   ): void;
+  addHandler(
+    eventType: T extends ClientProviderEvents ? ClientProviderEvents : ServerProviderEvents,
+    handler: EventHandler<T extends ClientProviderEvents ? ClientProviderEvents : ServerProviderEvents>,
+  ): void;
 
   /**
    * Removes a handler for the given provider event type.


Test patch:
diff --git a/packages/client/test/events.spec.ts b/packages/client/test/events.spec.ts
index f417fb62..5272694f 100644
--- a/packages/client/test/events.spec.ts
+++ b/packages/client/test/events.spec.ts
@@ -519,6 +519,16 @@ describe('Events', () => {
       // emit a change event from the mock provider
       provider.events?.emit(ProviderEvents.ConfigurationChanged, { flagsChanged: [changedFlag] });
     });
+
+    it('It allows iteration over all event types', () => {
+      // just a typings test; it should be possible to iterate over a collection of ProviderEvents,
+      const client = OpenFeature.getClient(domain);
+      const providerEvents: ProviderEvents[] = [];
+
+      providerEvents.forEach((e) => {
+        client.addHandler(e, () => {});
+      });
+    });
   });
 
   describe('Requirement 5.3.3', () => {
diff --git a/packages/server/test/events.spec.ts b/packages/server/test/events.spec.ts
index 4198d7da..044689c6 100644
--- a/packages/server/test/events.spec.ts
+++ b/packages/server/test/events.spec.ts
@@ -499,6 +499,16 @@ describe('Events', () => {
       // emit a change event from the mock provider
       provider.events?.emit(ProviderEvents.ConfigurationChanged, { flagsChanged: [changedFlag] });
     });
+
+    it('It allows iteration over all event types', () => {
+      // just a typings test; it should be possible to iterate over a collection of ProviderEvents,
+      const client = OpenFeature.getClient(domain);
+      const providerEvents: ProviderEvents[] = [];
+
+      providerEvents.forEach((e) => {
+        client.addHandler(e, () => {});
+      });
+    });
   });
   
   describe('Requirement 5.3.3', () => {
Repository: eclipse/microprofile-open-api
Pull request #272 (2018-09-18 04:26:12)

Add missing key parameter in Operation#addCallback()
In PR https://github.com/eclipse/microprofile-open-api/pull/249 I have introduced:

```
org.eclipse.microprofile.openapi.models.Operation.addCallback(Callback)
```

But `callbacks` in `Operation` is a `Map<String, Callback>`, so the method should be:

```
org.eclipse.microprofile.openapi.models.Operation.addCallback(String, Callback)
```

This PR adds the missing key parameter.

---

`1.1-SNAPSHOT` was not published yet, so I hope it is OK to fix this now.

---

cc: @EricWittmann, @arthurdm 

jmini: Thank you for the review.

I have modified Javadoc according to comment and rebased the PR on top of master.

Patch:
diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/Operation.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/Operation.java
index 884139b..1418784 100644
--- a/api/src/main/java/org/eclipse/microprofile/openapi/models/Operation.java
+++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/Operation.java
@@ -294,12 +294,13 @@ public interface Operation extends Constructible, Extensible<Operation> {
     }
 
     /**
-     * Adds the given callback item to this Operation's list of callbacks.
+     * Adds the given callback item to this Operation's map of callbacks.
      *
+     * @param key a key conforming to the format required for this object
      * @param callback a callback that is applicable for this operation
      * @return the current Operation object
      **/
-    Operation addCallback(Callback callback);
+    Operation addCallback(String key, Callback callback);
 
     /**
      * Returns the deprecated property from an Operation instance.


Test patch:
diff --git a/tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelConstructionTest.java b/tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelConstructionTest.java
index 1e41557..36864cc 100644
--- a/tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelConstructionTest.java
+++ b/tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelConstructionTest.java
@@ -269,6 +269,11 @@ public class ModelConstructionTest extends Arquillian {
         assertEquals(o.getTags().size(), 1, "The list is expected to contain one entry.");
         o.removeTag(tag);
         assertEquals(o.getTags().size(), 0, "The list is expected to be empty.");
+        
+        final String callbackKey = "myCallback";
+        final Callback callbackValue = createConstructibleInstance(Callback.class);
+        checkSameObject(o, o.addCallback(callbackKey, callbackValue));
+        checkMapEntry(o.getCallbacks(), callbackKey, callbackValue);
     }
     
     @Test
Repository: dropwizard/metrics
Pull request #4541 (2024-10-21 21:03:11)

fix: NoopTimer#time(Runnable) should run the Runnable
Fixes https://github.com/dropwizard/metrics/issues/4536


Patch:
diff --git a/metrics-core/src/main/java/io/dropwizard/metrics5/NoopMetricRegistry.java b/metrics-core/src/main/java/io/dropwizard/metrics5/NoopMetricRegistry.java
index db127a701..77f30124f 100644
--- a/metrics-core/src/main/java/io/dropwizard/metrics5/NoopMetricRegistry.java
+++ b/metrics-core/src/main/java/io/dropwizard/metrics5/NoopMetricRegistry.java
@@ -468,7 +468,7 @@ public final class NoopMetricRegistry extends MetricRegistry {
          */
         @Override
         public void time(Runnable event) {
-            // NOP
+            event.run();
         }
 
         /**


Test patch:
diff --git a/metrics-core/src/test/java/io/dropwizard/metrics5/NoopMetricRegistryTest.java b/metrics-core/src/test/java/io/dropwizard/metrics5/NoopMetricRegistryTest.java
index 7d2fc761c..894c315cf 100644
--- a/metrics-core/src/test/java/io/dropwizard/metrics5/NoopMetricRegistryTest.java
+++ b/metrics-core/src/test/java/io/dropwizard/metrics5/NoopMetricRegistryTest.java
@@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatNullPointerException;
@@ -494,4 +495,13 @@ class NoopMetricRegistryTest {
                 .isThrownBy(() -> registry.register(MetricName.build("any_name"), null))
                 .withMessage("metric == null");
     }
+
+    @Test
+    void timesRunnableInstances() {
+        Timer timer = registry.timer("thing");
+        final AtomicBoolean called = new AtomicBoolean();
+        timer.time(() -> called.set(true));
+
+        assertThat(called).isTrue();
+    }
 }