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

Update NPM packages #981

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { CamsSession } from '../../../../../common/src/cams/session';
import { UserSessionCacheRepository } from './user-session-cache.repository';
import { UnauthorizedError } from '../../common-errors/unauthorized-error';
import { CamsJwtClaims } from '../../../../../common/src/cams/jwt';
import { getCamsError } from '../../common-errors/error-utilities';
import { isConflictError } from '../../use-cases/user-session/user-session';

const MODULE_NAME: string = 'COSMOS_DB_REPOSITORY_USER_SESSION_CACHE';
const CONTAINER_NAME: string = 'user-session-cache';
Expand Down Expand Up @@ -38,7 +40,14 @@ export class UserSessionCacheCosmosDbRepository implements UserSessionCacheRepos
],
};

const cached = await this.repo.query(context, querySpec);
let cached;
try {
cached = await this.repo.query(context, querySpec);
} catch (error) {
if (isConflictError(error)) throw error;
throw getCamsError(error, MODULE_NAME);
}

if (cached && cached.length === 1) {
return toCamsSession(cached[0]);
} else {
Expand Down
15 changes: 9 additions & 6 deletions backend/functions/lib/use-cases/user-session/user-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,19 @@ export class UserSessionUseCase {
await sessionCacheRepository.put(context, session);

return session;
} catch (originalError) {
if (isConflictError(originalError)) {
} catch (error) {
const isConflict = error.originalError
? isConflictError(error.originalError)
: isConflictError(error);
Comment on lines +89 to +91
Copy link
Contributor

@jamesobrooks jamesobrooks Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some time back we wrapped up errors in the execute function on CosmosDbRepository. So here, the call to isConflictError was returning false (even when it should have been true).

if (isConflict) {
return await sessionCacheRepository.get(context, token);
}

throw isCamsError(originalError)
? originalError
throw isCamsError(error)
? error
: new UnauthorizedError(MODULE_NAME, {
message: originalError.message,
originalError,
message: error.message,
originalError: error,
});
}
}
Expand Down
1,095 changes: 920 additions & 175 deletions backend/functions/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@azure/functions": "^4.5.1",
"@azure/identity": "^4.4.1",
"@azure/keyvault-secrets": "^4.8.0",
"@launchdarkly/node-server-sdk": "^9.6.0",
"@launchdarkly/node-server-sdk": "^9.6.1",
"@okta/jwt-verifier": "^4.0.1",
"@okta/okta-sdk-nodejs": "^7.1.1",
"applicationinsights": "^3.3.0",
Expand Down
Loading
Loading