screwdriver-api 8.0.54 → 8.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "8.0.54",
3
+ "version": "8.0.56",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -69,31 +69,17 @@ const webhooksPlugin = {
69
69
  const { executor, queueWebhookEnabled } = queueWebhook;
70
70
  const message = 'Unable to process this kind of event';
71
71
  let hookId;
72
- let webhookSettings;
73
72
 
74
73
  try {
75
- const scmContexts = await scm.getScmContexts();
76
-
77
- scmContexts.forEach(scmContext => {
78
- if (pluginOptions[scmContext]) {
79
- webhookSettings = pluginOptions[scmContext];
80
- }
81
- });
82
-
83
- if (!webhookSettings) {
84
- logger.error(`No webhook settings found for scm context: ${scmContexts.join(', ')}`);
85
- throw boom.internal();
86
- }
87
-
88
74
  let size = 0;
89
75
  let data = '';
90
76
 
91
77
  for await (const chunk of request.payload) {
92
78
  size += chunk.length;
93
79
  data += chunk;
94
- if (size > (webhookSettings.maxBytes || DEFAULT_MAX_BYTES)) {
80
+ if (size > DEFAULT_MAX_BYTES) {
95
81
  throw boom.entityTooLarge(
96
- `Payload size exceeds the maximum limit of ${webhookSettings.maxBytes || DEFAULT_MAX_BYTES} bytes`
82
+ `Payload size exceeds the maximum limit of ${DEFAULT_MAX_BYTES} bytes`
97
83
  );
98
84
  }
99
85
  }
@@ -113,6 +99,13 @@ const webhooksPlugin = {
113
99
  return h.response({ message }).code(204);
114
100
  }
115
101
 
102
+ const webhookSettings = pluginOptions[parsed.scmContext];
103
+
104
+ if (!webhookSettings) {
105
+ logger.error(`No webhook settings found for scm context: ${parsed.scmContext}`);
106
+ throw boom.internal();
107
+ }
108
+
116
109
  parsed.pluginOptions = webhookSettings;
117
110
 
118
111
  const { type } = parsed;