screwdriver-api 4.1.202 → 4.1.203

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": "4.1.202",
3
+ "version": "4.1.203",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -115,6 +115,10 @@ module.exports = () => ({
115
115
  userFactory.get({ username, scmContext })
116
116
  ]);
117
117
 
118
+ if (!pipeline) {
119
+ throw boom.notFound();
120
+ }
121
+
118
122
  payload.scmContext = pipeline.scmContext;
119
123
 
120
124
  // In pipeline scope, check if the token is allowed to the pipeline
@@ -126,7 +130,16 @@ module.exports = () => ({
126
130
  const scmUri = await getScmUri({ pipeline, pipelineFactory });
127
131
 
128
132
  // Check the user's permission
129
- const permissions = await user.getPermissions(scmUri);
133
+ let permissions;
134
+
135
+ try {
136
+ permissions = await user.getPermissions(scmUri);
137
+ } catch (err) {
138
+ if (err.statusCode === 403 && (pipeline.scmRepo && pipeline.scmRepo.private)) {
139
+ throw boom.notFound();
140
+ }
141
+ throw boom.boomify(err, { statusCode: err.statusCode });
142
+ }
130
143
 
131
144
  // Update admins
132
145
  if (!prNum) {
@@ -187,8 +200,8 @@ module.exports = () => ({
187
200
  // User has good permissions, create an event
188
201
  sha = await scm.getCommitSha(scmConfig);
189
202
  } catch (err) {
190
- if (err.status) {
191
- throw boom.boomify(err, { statusCode: err.status });
203
+ if (err.statusCode) {
204
+ throw boom.boomify(err, { statusCode: err.statusCode });
192
205
  }
193
206
  }
194
207