Skip to content

Commit

Permalink
fix: change response code to bad request for unconfigured hostname (#401
Browse files Browse the repository at this point in the history
)

Being the internet, folks who probe the server with an invalid hostname
shouldn't raise 500 error alarms in monitoring.
  • Loading branch information
wkillerud committed May 13, 2024
1 parent f2f563e commit babc560
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/handlers/alias.delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const AliasDel = class AliasDel {

if (!org) {
this._log.info(`alias:del - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/alias.get.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const AliasGet = class AliasGet {

if (!org) {
this._log.info(`alias:get - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/alias.post.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const AliasPost = class AliasPost {

if (!org) {
this._log.info(`alias:post - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/alias.put.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const AliasPut = class AliasPut {

if (!org) {
this._log.info(`alias:put - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/auth.post.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const AuthPost = class AuthPost {

if (!org) {
this._log.info(`auth:post - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type: 'auth' } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/map.get.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const MapGet = class MapGet {

if (!org) {
this._log.info(`map:get - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type: 'map' } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/map.put.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const MapPut = class MapPut {

if (!org) {
this._log.info(`map:put - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type: 'map' } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/pkg.get.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const PkgGet = class PkgGet {

if (!org) {
this._log.info(`pkg:get - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/pkg.log.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const PkgLog = class PkgLog {

if (!org) {
this._log.info(`pkg:log - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/pkg.put.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const PkgPut = class PkgPut {

if (!org) {
this._log.info(`pkg:put - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type } });
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/versions.get.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const VersionsGet = class VersionsGet {

if (!org) {
this._log.info(`pkg:latest - Hostname does not match a configured organization - ${url.hostname}`);
const e = new HttpError.InternalServerError();
const e = new HttpError.BadRequest();
end({ labels: { success: false, status: e.status, type } });
throw e;
}
Expand Down

0 comments on commit babc560

Please sign in to comment.