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

fix: no detailed error message in AAD app actions #8737

Merged
merged 1 commit into from
May 19, 2023
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
4 changes: 2 additions & 2 deletions packages/fx-core/src/component/driver/aad/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ export class CreateAadAppDriver implements StepDriver {
);
if (error.response!.status >= 400 && error.response!.status < 500) {
return {
result: err(new UnhandledUserError(error as Error, actionName, helpLink)),
result: err(new UnhandledUserError(new Error(message), actionName, helpLink)),
summaries: summaries,
};
} else {
return {
result: err(new UnhandledError(error as Error, actionName)),
result: err(new UnhandledError(new Error(message), actionName)),
summaries: summaries,
};
}
Expand Down
4 changes: 2 additions & 2 deletions packages/fx-core/src/component/driver/aad/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ export class UpdateAadAppDriver implements StepDriver {
);
if (error.response!.status >= 400 && error.response!.status < 500) {
return {
result: err(new UnhandledUserError(error as Error, actionName, helpLink)),
result: err(new UnhandledUserError(new Error(message), actionName, helpLink)),
summaries: summaries,
};
} else {
return {
result: err(new UnhandledError(error as Error, actionName)),
result: err(new UnhandledError(new Error(message), actionName)),
summaries: summaries,
};
}
Expand Down
8 changes: 6 additions & 2 deletions packages/fx-core/tests/component/driver/aad/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ describe("aadAppCreate", async () => {
expect(result.result._unsafeUnwrapErr())
.is.instanceOf(UnhandledUserError)
.and.has.property("message")
.and.contains("An unexpected error has occurred while performing the aadApp/create task");
.and.equals(
'An unexpected error has occurred while performing the aadApp/create task. {"error":{"code":"Request_BadRequest","message":"Invalid value specified for property \'displayName\' of resource \'Application\'."}}'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jidddddd can you help review the new message? The API response various in different situation, so we put the raw response here to avoid missing useful information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jayzhang Please also help review the new message in case it violates the error message practices.

);
});

it("should throw system error when AadAppClient failed with non 4xx error", async () => {
Expand All @@ -354,7 +356,9 @@ describe("aadAppCreate", async () => {
expect(result.result._unsafeUnwrapErr())
.is.instanceOf(UnhandledError)
.and.has.property("message")
.and.contains("An unexpected error has occurred while performing the aadApp/create task");
.and.equals(
'An unexpected error has occurred while performing the aadApp/create task. {"error":{"code":"InternalServerError","message":"Internal server error"}}'
);
});

it("should send telemetries when success", async () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/fx-core/tests/component/driver/aad/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ describe("aadAppUpdate", async () => {
expect(result.result._unsafeUnwrapErr())
.is.instanceOf(UnhandledUserError)
.and.property("message")
.contain("An unexpected error has occurred while performing the aadApp/update task");
.equals(
'An unexpected error has occurred while performing the aadApp/update task. {"error":{"code":"Request_BadRequest","message":"Invalid value specified for property \'displayName\' of resource \'Application\'."}}'
);
});

it("should throw system error when AadAppClient failed with non 4xx error", async () => {
Expand Down Expand Up @@ -447,7 +449,9 @@ describe("aadAppUpdate", async () => {
expect(result.result._unsafeUnwrapErr())
.is.instanceOf(UnhandledError)
.and.property("message")
.contain("An unexpected error has occurred while performing the aadApp/update task");
.equals(
'An unexpected error has occurred while performing the aadApp/update task. {"error":{"code":"InternalServerError","message":"Internal server error"}}'
);
});

it("should send telemetries when success", async () => {
Expand Down