Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix service crash when non-arsenal errors is sent to delete route #2267

Merged
merged 12 commits into from
Nov 26, 2024
Merged
15 changes: 9 additions & 6 deletions lib/s3routes/routes/routeDELETE.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RequestLogger } from 'werelogs';

import * as routesUtils from '../routesUtils';
import errors from '../../errors';
import errors, { ArsenalError } from '../../errors';
import StatsClient from '../../metrics/StatsClient';
import * as http from 'http';

Expand Down Expand Up @@ -54,11 +54,14 @@ export default function routeDELETE(
api.callApiMethod('objectDelete', request, response, log,
(err, corsHeaders) => {
/*
* Since AWS expects a 204 regardless of the existence of
the object, the errors NoSuchKey and NoSuchVersion should not
* be sent back as a response.
*/
if (err && !err.is.NoSuchKey && !err.is.NoSuchVersion) {
* Since AWS expects a 204 regardless of the existence of
* the object, the errors NoSuchKey and NoSuchVersion should not
* be sent back as a response.
*/
if (err && (
!(err instanceof ArsenalError) ||
(!err.is.NoSuchKey && err.is.NoSuchVersion)
)) {
return routesUtils.responseNoBody(err, corsHeaders,
response, undefined, log);
}
Expand Down
2 changes: 0 additions & 2 deletions lib/s3routes/routes/routeGET.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ export default function routerGET(
if (resMetaHeaders && resMetaHeaders['Content-Length']) {
contentLength = resMetaHeaders['Content-Length'];
}
// TODO ARSN-216 Fix logger
// @ts-ignore
log.end().addDefaultFields({ contentLength });
francoisferrand marked this conversation as resolved.
Show resolved Hide resolved
routesUtils.statsReport500(err, statsClient);
return routesUtils.responseStreamData(err, query,
Expand Down
4 changes: 1 addition & 3 deletions lib/s3routes/routes/routePUT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ export default function routePUT(
return routesUtils.responseNoBody(errors.BadRequest,
null, response, 400, log);
}
// TODO ARSN-216 What's happening?
// @ts-ignore
log.end().addDefaultFields({ contentLength: request.parsedContentLength });
log.end().addDefaultFields({ contentLength: parsedContentLength });
api.callApiMethod('objectPut', request, response, log,
(err, resHeaders) => {
routesUtils.statsReport500(err, statsClient);
Expand Down
Loading
Loading