PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: jenkins-x/lighthouse (go)
Issue: Panic in util.ExternalPluginsForEvent when there is no agent configuration
```
2020/08/18 13:17:24 http: panic serving [::1]:63875: runtime error: invalid memory address or nil pointer dereference
goroutine 100 [running]:
net/http.(*conn).serve.func1(0xc0000db0e0)
        /Users/hardy/.gvm/gos/go1.13.15/src/net/http/server.go:1795 +0x139
panic(0x22c6300, 0x3399f90)
        /Users/hardy/.gvm/gos/go1.13.15/src/runtime/panic.go:679 +0x1b2
github.com/jenkins-x/lighthouse/pkg/util.ExternalPluginsForEvent(0xc0001fb790, 0x24d36bb, 0x4, 0xc0004e5f40, 0x1a, 0xc0004fb970, 0xf, 0xc0004e5f40)
        /Users/hardy/work/go/src/github.com/jenkins-x/lighthouse/pkg/util/externalplugins.go:262 +0xb4
github.com/jenkins-x/lighthouse/pkg/webhook.(*Options).handleWebHookRequests(0xc0000f0420, 0x27687c0, 0xc0004c01c0, 0xc000474200)
        /Users/hardy/work/go/src/github.com/jenkins-x/lighthouse/pkg/webhook/webhook.go:251 +0x94a
net/http.HandlerFunc.ServeHTTP(0xc000407180, 0x27687c0, 0xc0004c01c0, 0xc000474200)
        /Users/hardy/.gvm/gos/go1.13.15/src/net/http/server.go:2036 +0x44
net/http.(*ServeMux).ServeHTTP(0xc0000ec6c0, 0x27687c0, 0xc0004c01c0, 0xc000474200)
        /Users/hardy/.gvm/gos/go1.13.15/src/net/http/server.go:2416 +0x1bd
net/http.serverHandler.ServeHTTP(0xc0004c00e0, 0x27687c0, 0xc0004c01c0, 0xc000474200)
        /Users/hardy/.gvm/gos/go1.13.15/src/net/http/server.go:2831 +0xa4
net/http.(*conn).serve(0xc0000db0e0, 0x276ea80, 0xc0000eda40)
        /Users/hardy/.gvm/gos/go1.13.15/src/net/http/server.go:1919 +0x875
created by net/http.(*Server).Serve
        /Users/hardy/.gvm/gos/go1.13.15/src/net/http/server.go:2957 +0x384
```

Pull request description: fix: adding nil check for pluginConfig.Config() in util.ExternalPluginsForEvent
fixes #934

Patch:
diff --git a/pkg/util/externalplugins.go b/pkg/util/externalplugins.go
index 8626c72c..4e9753b2 100644
--- a/pkg/util/externalplugins.go
+++ b/pkg/util/externalplugins.go
@@ -253,6 +253,10 @@ func dispatch(endpoint string, payload []byte, h http.Header) error {
 // get the present event.
 func ExternalPluginsForEvent(pluginConfig *plugins.ConfigAgent, eventKind string, srcRepo string) []plugins.ExternalPlugin {
 	var matching []plugins.ExternalPlugin
+	if pluginConfig.Config() == nil {
+		return matching
+	}
+
 	srcOrg := strings.Split(srcRepo, "/")[0]
 
 	for repo, extPlugins := range pluginConfig.Config().ExternalPlugins {


Test patch:
diff --git a/pkg/util/externalplugins_test.go b/pkg/util/externalplugins_test.go
new file mode 100644
index 00000000..5d10f74b
--- /dev/null
+++ b/pkg/util/externalplugins_test.go
@@ -0,0 +1,15 @@
+package util_test
+
+import (
+	"testing"
+
+	"github.com/jenkins-x/lighthouse/pkg/plugins"
+	"github.com/jenkins-x/lighthouse/pkg/util"
+	"github.com/stretchr/testify/require"
+)
+
+func Test_ExternalPluginsForEvent_returns_empty_slice_for_nil_configuration(t *testing.T) {
+	configAgent := &plugins.ConfigAgent{}
+	plugins := util.ExternalPluginsForEvent(configAgent, util.LighthousePayloadTypeActivity, "myorg/myrepo")
+	require.Empty(t, plugins)
+}
Repository: marpple/FxTS (ts)
Issue: Add `isNil` function
# Suggestion

<!--
  Please fill in each section completely. Thank you!
-->

## ⭐ Suggestion

<!-- What would you like to be added? -->

Checks if the given value is `null` or `undefined`.

## 💻 Use Cases

<!-- What do you want to use this for? -->
```
isNil(1); // false
isNil('1'); // false
isNil(undefined); // true
isNil(null); // true
```
Pull request description: feat: add `isNil` function
Fixes #43


Patch:
diff --git a/src/index.ts b/src/index.ts
index f0f62157..a0b2cf40 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -8,6 +8,7 @@ import head from "./head";
 import identity from "./identity";
 import indexBy from "./indexBy";
 import isArray from "./isArray";
+import isNil from "./isNil";
 import isString from "./isString";
 import join from "./join";
 import last from "./last";
@@ -34,6 +35,7 @@ export {
   identity,
   indexBy,
   isArray,
+  isNil,
   isString,
   join,
   last,
diff --git a/src/isNil.ts b/src/isNil.ts
new file mode 100644
index 00000000..78ce7caa
--- /dev/null
+++ b/src/isNil.ts
@@ -0,0 +1,20 @@
+type Nullable<T> = T extends null | undefined ? T : never;
+
+/**
+ * Checks if the given value is `null` or `undefined`.
+ *
+ * @example
+ * isNil(1); // false
+ * isNil('1'); // false
+ * isNil(undefined); // true
+ * isNil(null); // true
+ */
+function isNil<T>(a: T): a is Nullable<T> {
+  if (a === undefined || a === null) {
+    return true;
+  }
+
+  return false;
+}
+
+export default isNil;


Test patch:
diff --git a/test/isNil.spec.ts b/test/isNil.spec.ts
new file mode 100644
index 00000000..2117afbc
--- /dev/null
+++ b/test/isNil.spec.ts
@@ -0,0 +1,26 @@
+import { isNil } from "../src/index";
+
+describe("isNil", function () {
+  it("should check if given value is `null` or `undefined`", function () {
+    const res1 = isNil(null);
+    expect(res1).toEqual(true);
+
+    const res2 = isNil(undefined);
+    expect(res2).toEqual(true);
+
+    const res3 = isNil(3);
+    expect(res3).toEqual(false);
+
+    const res4 = isNil("3");
+    expect(res4).toEqual(false);
+
+    const res5 = isNil({});
+    expect(res5).toEqual(false);
+
+    const res6 = isNil(Symbol("3"));
+    expect(res6).toEqual(false);
+
+    const res7 = isNil(false);
+    expect(res7).toEqual(false);
+  });
+});
diff --git a/type-check/isNil.test.ts b/type-check/isNil.test.ts
new file mode 100644
index 00000000..561cc415
--- /dev/null
+++ b/type-check/isNil.test.ts
@@ -0,0 +1,29 @@
+import * as Test from "../src/types/Test";
+import { isNil, map, pipe, toArray } from "../src";
+
+const { checks, check } = Test;
+
+type User = {
+  name?: string | null;
+  age: number;
+};
+
+const user: User = {
+  age: 23,
+};
+
+function getUserName(user: User) {
+  if (!isNil(user.name)) {
+    return user.name;
+  }
+
+  throw new Error("Not exist user's name");
+}
+
+const res1 = getUserName(user);
+const res2 = pipe([user, user, user], map(getUserName), toArray);
+
+checks([
+  check<typeof res1, string, Test.Pass>(),
+  check<typeof res2, string[], Test.Pass>(),
+]);