PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: edgurgel/mimic (elixir)
Issue: Calling `stub_with/2` with a second module that doesn't exist causes Mimic to fail in unpredictable ways
It's late, so I haven't crafted a reproducer, but I renamed a module that was being stubbed elsewhere in my code and didn't change it there. Then a bunch of tests failed saying that other completely unrelated modules hadn't been copied, when they definitely had. Other times the Mimic genserver crashed outright.
Pull request description: Fix stub with undefined
Fixes #54 

Patch:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index dc62a5d..ebbc4c0 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -12,8 +12,8 @@ jobs:
       - name: Install OTP and Elixir
         uses: erlef/setup-elixir@v1
         with:
-          otp-version: 23.1.1
-          elixir-version: 1.11.2
+          otp-version: 24.3
+          elixir-version: 1.13.3
 
       - name: Install dependencies
         run: mix deps.get
@@ -37,8 +37,6 @@ jobs:
           - otp: 24.3
             elixir: 1.13.3
             coverage: true
-          - otp: 23.1.1
-            elixir: 1.11.3
           - otp: 24.3
             elixir: 1.12.3
     env:
diff --git a/lib/mimic.ex b/lib/mimic.ex
index 52bf548..7326297 100644
--- a/lib/mimic.ex
+++ b/lib/mimic.ex
@@ -182,6 +182,8 @@ defmodule Mimic do
   """
   @spec stub_with(module(), module()) :: module()
   def stub_with(module, mocking_module) do
+    raise_if_module_not_defined!(mocking_module)
+
     module
     |> Server.stub_with(mocking_module)
     |> validate_server_response(:stub)
@@ -468,6 +470,12 @@ defmodule Mimic do
     end
   end
 
+  defp raise_if_module_not_defined!(module) do
+    unless Code.ensure_loaded?(module) do
+      raise ArgumentError, "Module #{inspect(module)} not defined"
+    end
+  end
+
   defp validate_server_response({:ok, module}, _action), do: module
 
   defp validate_server_response({:error, :not_global_owner}, :reject) do


Test patch:
diff --git a/test/mimic_test.exs b/test/mimic_test.exs
index 5ffaa0e..cdde541 100644
--- a/test/mimic_test.exs
+++ b/test/mimic_test.exs
@@ -112,7 +112,7 @@ defmodule Mimic.Test do
     end
   end
 
-  describe "stub_with/1 private mode" do
+  describe "stub_with/2 private mode" do
     setup :set_mimic_private
 
     test "called multiple times" do
@@ -127,6 +127,22 @@ defmodule Mimic.Test do
 
       assert_raise Mimic.UnexpectedCallError, fn -> Calculator.mult(4, 9) end
     end
+
+    test "undefined mocking module" do
+      assert_raise ArgumentError,
+                   "Module MissingModule not defined",
+                   fn ->
+                     stub_with(Calculator, MissingModule)
+                   end
+    end
+
+    test "undefined mocked module" do
+      assert_raise ArgumentError,
+                   "Module MissingModule has not been copied.  See docs for Mimic.copy/1",
+                   fn ->
+                     stub_with(MissingModule, InverseCalculator)
+                   end
+    end
   end
 
   describe "stub/3 private mode" do
Repository: Kong/swrv (ts)
Issue: revalidations firing when key is falsy
revalidations are firing even if the key value returns falsy
Pull request description: fix(revalidation) dont fire if key is falsy
Fixes #64

Patch:
diff --git a/src/use-swrv.ts b/src/use-swrv.ts
index 0537d42..3a93df4 100644
--- a/src/use-swrv.ts
+++ b/src/use-swrv.ts
@@ -177,7 +177,7 @@ export default function useSWRV<Data = any, Error = any> (key: IKey, fn?: fetche
    */
   const revalidate = async (data?: fetcherFn<Data>) => {
     const keyVal = keyRef.value
-    if (!isDocumentVisible()) { return }
+    if (!isDocumentVisible() || !keyVal) { return }
     const cacheItem = config.cache.get(keyVal)
     let newData = cacheItem && cacheItem.data
 


Test patch:
diff --git a/tests/use-swrv.spec.tsx b/tests/use-swrv.spec.tsx
index 8ca9e98..8550e78 100644
--- a/tests/use-swrv.spec.tsx
+++ b/tests/use-swrv.spec.tsx
@@ -213,6 +213,55 @@ describe('useSWRV', () => {
     done()
   })
 
+  it('should not revalidate if key is falsy', async done => {
+    let count = 0
+    const fetch = key => {
+      count++
+      return new Promise(res => setTimeout(() => res(key), 100))
+    }
+    const vm = new Vue({
+      template: `<div>{{ e1 }}</div>`,
+      setup  () {
+        const someDep = ref(undefined)
+        const { data: e1 } = useSWRV(() => someDep.value, fetch, {
+          refreshInterval: 1000
+        })
+
+        return { e1 }
+      }
+    }).$mount()
+
+    // Does not fetch on mount
+    expect(count).toBe(0)
+    expect(vm.$el.textContent).toBe('')
+    timeout(100)
+    await tick(vm, 2)
+    expect(count).toBe(0)
+    expect(vm.$el.textContent).toBe('')
+
+    // Does not revalidate even after some time passes
+    timeout(100)
+    await tick(vm, 2)
+    expect(count).toBe(0)
+    expect(vm.$el.textContent).toBe('')
+
+    // does not revalidate on refresh interval
+    timeout(1000)
+    await tick(vm, 2)
+    expect(count).toBe(0)
+    expect(vm.$el.textContent).toBe('')
+
+    // does not revalidate on tab changes
+    let evt = new Event('visibilitychange')
+    document.dispatchEvent(evt)
+    timeout(100)
+    await tick(vm, 2)
+    expect(count).toBe(0)
+    expect(vm.$el.textContent).toBe('')
+
+    done()
+  })
+
   // From #24
   it('should only update refs of current cache key', async done => {
     const fetcher = (key) => new Promise(res => setTimeout(() => res(key), 1000))