From 02b3315991cbc2cca36d61e9fe6173dd49f5b239 Mon Sep 17 00:00:00 2001 From: Valtteri Kantanen Date: Wed, 21 Aug 2024 14:32:54 +0300 Subject: [PATCH] [Study guidance groups] Fix fetching of user's study guidance groups --- services/backend/src/services/studyGuidanceGroups.ts | 7 +++++++ services/backend/src/util/importerClient.ts | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/services/backend/src/services/studyGuidanceGroups.ts b/services/backend/src/services/studyGuidanceGroups.ts index 54fd42e4b4..e30fffaf7a 100644 --- a/services/backend/src/services/studyGuidanceGroups.ts +++ b/services/backend/src/services/studyGuidanceGroups.ts @@ -1,3 +1,5 @@ +import * as Sentry from '@sentry/node' +import { AxiosError } from 'axios' import { uniq } from 'lodash' import { StudyGuidanceGroupTag } from '../models/kone' @@ -55,6 +57,11 @@ const getGroupsFromImporter = async (sisPersonId: string) => { return studyGuidanceGroups } catch (error) { logger.error("Couldn't fetch users study guidance groups") + if (error instanceof AxiosError) { + logger.error(error.stack) + logger.error(JSON.stringify(error.response?.data)) + Sentry.captureException(error) + } return [] } } diff --git a/services/backend/src/util/importerClient.ts b/services/backend/src/util/importerClient.ts index a9351f6081..50015718f0 100644 --- a/services/backend/src/util/importerClient.ts +++ b/services/backend/src/util/importerClient.ts @@ -28,7 +28,7 @@ const getFdImporterClient = () => { logger.error("Basic auth credentials not set, can't return client!") return null } - return toskaImporterClient + return fdImporterClient } const getToskaImporterClient = () => { @@ -36,7 +36,7 @@ const getToskaImporterClient = () => { logger.error("Importer token not set, can't return client!") return null } - return fdImporterClient + return toskaImporterClient } export const getImporterClient = serviceProvider === 'toska' ? getToskaImporterClient : getFdImporterClient