Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed Nov 28, 2024
1 parent 58ffd77 commit 54fc5f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
17 changes: 8 additions & 9 deletions lib/s3routes/routesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,10 @@ export const XMLResponseBackend = {
) {
setCommonResponseHeaders(corsHeaders, response, log);
let error: ArsenalError;
let description: string;
if (errCode instanceof ArsenalError) {
error = errCode;
description = errCode.description;
} else {
error = errors.InternalError.customizeDescription(errCode.message);
description = errCode.message;
}
// early return to avoid extra headers and XML data
if (error.code === 304) {
Expand All @@ -148,10 +145,10 @@ export const XMLResponseBackend = {
*/
const xml: string[] = [];
xml.push(
'<?xml version="1.0" encoding="UTF-8"?>',
'<Error>',
`<Code>${errCode.message}</Code>`,
`<Message>${description}</Message>`,
`<?xml version="1.0" encoding="UTF-8"?>`,

Check warning on line 148 in lib/s3routes/routesUtils.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
`<Error>`,

Check warning on line 149 in lib/s3routes/routesUtils.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
`<Code>${error.message}</Code>`,
`<Message>${error.description}</Message>`,
);
const invalidArguments = error.metadata.get('invalidArguments') || [];
invalidArguments.forEach((invalidArgument, index) => {
Expand All @@ -161,13 +158,15 @@ export const XMLResponseBackend = {
xml.push(`<ArgumentValue${counter}>${ArgumentValue}</ArgumentValue${counter}>`);
});
xml.push(
'<Resource></Resource>',
`<Resource></Resource>`,

Check warning on line 161 in lib/s3routes/routesUtils.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
`<RequestId>${log.getSerializedUids()}</RequestId>`,
'</Error>',
`</Error>`,

Check warning on line 163 in lib/s3routes/routesUtils.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
);
const xmlStr = xml.join('');
console.log(xmlStr);

Check failure on line 166 in lib/s3routes/routesUtils.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
const bytesSent = Buffer.byteLength(xmlStr);
log.addDefaultFields({ bytesSent });
console.log(bytesSent);

Check failure on line 169 in lib/s3routes/routesUtils.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
response.writeHead(error.code, {
'Content-Type': 'application/xml',
'Content-Length': bytesSent ,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"sproxydclient": "github:scality/sproxydclient#8.1.0",
"utf8": "^3.0.0",
"uuid": "^10.0.0",
"werelogs": "github:scality/werelogs#8.2.2",
"werelogs": "scality/werelogs#8.2.2",
"xml2js": "^0.6.2"
},
"optionalDependencies": {
Expand Down Expand Up @@ -89,7 +89,7 @@
"build": "tsc",
"prepare": "yarn build",
"ft_test": "jest tests/functional --testTimeout=120000 --forceExit",
"coverage": "nyc --clean jest tests --coverage --testTimeout=120000 --forceExit",
"coverage": "nyc --clean jest tests/unit/s3routes/routesUtils/XMLResponseBackend.spec.js --coverage --testTimeout=120000 --forceExit",
"build_doc": "cd documentation/listingAlgos/pics; dot -Tsvg delimiterStateChart.dot > delimiterStateChart.svg; dot -Tsvg delimiterMasterV0StateChart.dot > delimiterMasterV0StateChart.svg; dot -Tsvg delimiterVersionsStateChart.dot > delimiterVersionsStateChart.svg"
},
"private": true,
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7628,16 +7628,16 @@ webidl-conversions@^7.0.0:
fast-safe-stringify "^2.1.1"
safe-json-stringify "^1.2.0"

"werelogs@github:scality/werelogs#8.2.2":
version "8.2.2"
resolved "https://codeload.github.com/scality/werelogs/tar.gz/e53bef5145697bf8af940dcbe59408988d64854f"
werelogs@scality/werelogs#8.2.0:
version "8.2.0"
resolved "https://codeload.github.com/scality/werelogs/tar.gz/7bf334cea94002d118f27d7ec1c7a5af74b51b8d"
dependencies:
fast-safe-stringify "^2.1.1"
safe-json-stringify "^1.2.0"

werelogs@scality/werelogs#8.2.0:
version "8.2.0"
resolved "https://codeload.github.com/scality/werelogs/tar.gz/7bf334cea94002d118f27d7ec1c7a5af74b51b8d"
werelogs@scality/werelogs#8.2.2:
version "8.2.2"
resolved "https://codeload.github.com/scality/werelogs/tar.gz/e53bef5145697bf8af940dcbe59408988d64854f"
dependencies:
fast-safe-stringify "^2.1.1"
safe-json-stringify "^1.2.0"
Expand Down

0 comments on commit 54fc5f0

Please sign in to comment.