Skip to content

Commit

Permalink
Merge pull request #400 from vscheuber/main
Browse files Browse the repository at this point in the history
fixes #392
  • Loading branch information
vscheuber authored Apr 8, 2024
2 parents 5085f9b + df7f0d6 commit d01b865
Show file tree
Hide file tree
Showing 28 changed files with 416 additions and 297 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- \#392: Implemented error handling pattern for methods with unusual amounts of REST calls like `frodo.config.exportFullConfiguration` and `frodo.config.importFullConfiguration`

## [2.0.0-75] - 2024-03-29

### Fixed
Expand Down
8 changes: 2 additions & 6 deletions src/api/IdmConfigApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,8 @@ export async function putConfigEntity({
getHostBaseUrl(state.getHost()),
entityId
);
try {
const { data } = await generateIdmApi({ state }).put(urlString, entityData);
return data;
} catch (error) {
throw Error(`Error on config entity ${entityId}: ${error}`);
}
const { data } = await generateIdmApi({ state }).put(urlString, entityData);
return data;
}

/**
Expand Down
9 changes: 1 addition & 8 deletions src/ops/ApplicationOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,6 @@ export async function importApplications({
}): Promise<ApplicationSkeleton[]> {
const response = [];
const errors = [];
const imported = [];
try {
for (const applicationId of Object.keys(importData.managedApplication)) {
const applicationData = importData.managedApplication[applicationId];
Expand All @@ -1402,23 +1401,17 @@ export async function importApplications({
state,
})
);
imported.push(applicationId);
} catch (error) {
errors.push(error);
}
}
if (errors.length) {
throw new FrodoError(`Error importing applications`, errors);
}
if (0 === imported.length) {
throw new FrodoError(
`Import error:\nNo applications found in import data!`
);
}
return response;
} catch (error) {
// just re-throw previously caught errors
if (errors.length > 0 || imported.length == 0) {
if (errors.length > 0) {
throw error;
}
throw new FrodoError(`Error importing applications`, error);
Expand Down
2 changes: 1 addition & 1 deletion src/ops/AuthenticateOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ export async function getFreshSaBearerToken({
const err: FrodoError = error as FrodoError;
if (
err.isHttpError &&
err.httpErrorMessage === 'invalid_scope' &&
err.httpErrorText === 'invalid_scope' &&
err.httpDescription?.startsWith('Unsupported scope for service account: ')
) {
const invalidScopes: string[] = err.httpDescription
Expand Down
11 changes: 1 addition & 10 deletions src/ops/CirclesOfTrustOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ export async function importCirclesOfTrust({
}): Promise<CircleOfTrustSkeleton[]> {
const responses = [];
const errors = [];
const imported = [];
try {
entityProviders = entityProviders.map((id) => `${id}|saml2`);
const validEntityIds = await readSaml2EntityIds({ state });
Expand Down Expand Up @@ -736,7 +735,6 @@ export async function importCirclesOfTrust({
cotData,
state,
});
imported.push(cotId);
responses.push(response);
} catch (createError) {
if ((createError as FrodoError).httpStatus === 409) {
Expand Down Expand Up @@ -770,7 +768,6 @@ export async function importCirclesOfTrust({
cotData: existingCot,
state,
});
imported.push(cotId);
responses.push(response);
} else {
debugMessage({
Expand Down Expand Up @@ -848,20 +845,14 @@ export async function importCirclesOfTrust({
});
errors.push(error);
}
imported.push(cotId);
}
if (errors.length > 0) {
throw new FrodoError(`Error importing circles of trust`);
}
if (0 === imported.length) {
throw new Error(
`Import error:\nNo circles of trust found in import data!`
);
}
return responses;
} catch (error) {
// just re-throw previously caught errors
if (errors.length > 0 || imported.length == 0) {
if (errors.length > 0) {
throw error;
}
throw new FrodoError(`Error importing circles of trust`, error);
Expand Down
Loading

0 comments on commit d01b865

Please sign in to comment.