Skip to content

Commit

Permalink
refactor: change in credentials function validation code
Browse files Browse the repository at this point in the history
  • Loading branch information
kanishkkatara committed Jun 19, 2024
1 parent 3db810c commit 7b0ea80
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/util/ivmFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,15 @@ async function createIvm(

await jail.set('_credential', function (key) {
if (isNil(credentials) || !isObject(credentials)) {
logger.error('Error fetching credentials map', versionId);
logger.error(

Check warning on line 257 in src/util/ivmFactory.js

View check run for this annotation

Codecov / codecov/patch

src/util/ivmFactory.js#L257

Added line #L257 was not covered by tests
`Error fetching credentials map for transformationID: ${transformationId} and workspaceId: ${workspaceId}`,
);
stats.increment('credential_error_total', { transformationId, workspaceId });
return undefined;

Check warning on line 261 in src/util/ivmFactory.js

View check run for this annotation

Codecov / codecov/patch

src/util/ivmFactory.js#L260-L261

Added lines #L260 - L261 were not covered by tests
}
if (key === null || key === undefined) {
throw new TypeError('Key should be valid and defined');
}
return credentials[key];
});

Expand Down Expand Up @@ -343,9 +348,6 @@ async function createIvm(
delete _credential;
global.credential = function(...args) {
const key = args[0];
if (key === null || key === undefined) {
throw new TypeError('Key should be valid and defined');
}
return credential(new ivm.ExternalCopy(key).copyInto());
};
Expand Down

0 comments on commit 7b0ea80

Please sign in to comment.