Repository: octokit/webhooks.js
Pull request #801 (2023-01-13 17:04:35)

fix(logging): change error to warn
<!-- Please refer to our contributing docs for any questions on submitting a pull request -->


<!-- Issues are required for both bug fixes and features. -->
Resolves https://github.com/octokit/webhooks.js/pull/790#discussion_r1069666880

----

## Behavior

### Before the change?
<!-- Please describe the current behavior that you are modifying. -->

* Logging would use error, which could make jest confused.

### After the change?
<!-- Please describe the behavior or changes that are being added by this PR. -->

* Use warn for logging


### Other information
<!-- Any other information that is important to this PR  -->

*

----

## Additional info

### Pull request checklist
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been reviewed and added / updated if needed (for bug fixes / features)
- [x] Added the appropriate label for the given change

### Does this introduce a breaking change?
<!-- If this introduces a breaking change make sure to note it here any what the impact might be -->

Please see our docs on [breaking changes](https://github.com/octokit/.github/blob/main/community/breaking_changes.md) to help!

- [ ] Yes (Please add the `Type: Breaking change` label)
- [x] No

If `Yes`, what's the impact:

* N/A


### Pull request type

<!-- Please do not submit updates to dependencies unless it fixes an issue. -->
<!-- Please try to limit your pull request to one type, submit multiple pull requests if needed. -->

Please add the corresponding label for change this PR introduces:
- Bugfix: `Type: Bug`
- Feature/model/API additions: `Type: Feature`
- Updates to docs or samples: `Type: Documentation`
- Dependencies/code cleanup: `Type: Maintenance`

----



wolfy1339: The tests need to be updated to reflect the change

Patch:
diff --git a/src/index.ts b/src/index.ts
index 06fba3a..436df1b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -62,7 +62,7 @@ class Webhooks<TTransformed = unknown> {
     this.sign = sign.bind(null, options.secret);
     this.verify = (eventPayload: object | string, signature: string) => {
       if (typeof eventPayload === "object") {
-        console.error(
+        console.warn(
           "[@octokit/webhooks] Passing a JSON payload object to `verify()` is deprecated and the functionality will be removed in a future release of `@octokit/webhooks`"
         );
       }
@@ -79,7 +79,7 @@ class Webhooks<TTransformed = unknown> {
         | EmitterWebhookEventWithSignature
     ) => {
       if (typeof options.payload === "object") {
-        console.error(
+        console.warn(
           "[@octokit/webhooks] Passing a JSON payload object to `verifyAndReceive()` is deprecated and the functionality will be removed in a future release of `@octokit/webhooks`"
         );
       }
diff --git a/src/middleware/node/get-payload.ts b/src/middleware/node/get-payload.ts
index 360acf1..ff659e5 100644
--- a/src/middleware/node/get-payload.ts
+++ b/src/middleware/node/get-payload.ts
@@ -20,7 +20,7 @@ export function getPayload(
 
   if (request.body) {
     if (typeof request.body !== "string") {
-      console.error(
+      console.warn(
         "[@octokit/webhooks] Passing the payload as a JSON object in `request.body` is deprecated and will be removed in a future release of `@octokit/webhooks`, please pass it as a a `string` instead."
       );
     }
diff --git a/src/middleware/node/index.ts b/src/middleware/node/index.ts
index 46398af..ebd68b5 100644
--- a/src/middleware/node/index.ts
+++ b/src/middleware/node/index.ts
@@ -13,7 +13,7 @@ export function createNodeMiddleware(
   }: MiddlewareOptions = {}
 ) {
   const deprecateOnUnhandledRequest = (request: any, response: any) => {
-    console.error(
+    console.warn(
       "[@octokit/webhooks] `onUnhandledRequest()` is deprecated and will be removed in a future release of `@octokit/webhooks`"
     );
     return onUnhandledRequest(request, response);


Test patch:
diff --git a/test/unit/deprecation.test.ts b/test/unit/deprecation.test.ts
index af7584a..ed132a4 100644
--- a/test/unit/deprecation.test.ts
+++ b/test/unit/deprecation.test.ts
@@ -19,7 +19,7 @@ describe("Deprecations", () => {
     );
   });
   test("onUnhandledRequest", async () => {
-    const spy = jest.spyOn(console, "error");
+    const spy = jest.spyOn(console, "warn");
     const webhooks = new Webhooks({
       secret: "mySecret",
     });
@@ -54,7 +54,7 @@ describe("Deprecations", () => {
   });
 
   test("webhooks.verify(payload, signature) with object payload", async () => {
-    const spy = jest.spyOn(console, "error");
+    const spy = jest.spyOn(console, "warn");
     const secret = "mysecret";
     const webhooks = new Webhooks({ secret });
 
@@ -69,7 +69,7 @@ describe("Deprecations", () => {
   });
 
   test("webhooks.verifyAndReceive(payload, signature) with object payload", async () => {
-    const spy = jest.spyOn(console, "error");
+    const spy = jest.spyOn(console, "warn");
     const secret = "mysecret";
     const webhooks = new Webhooks({ secret });