forked from gitpod-io/gitpod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[server, dashboard] improve single prebuild view (gitpod-io#19445)
* [server] proper handle prebuild log stream response * Write error message to body * Check read_prebuild permission on organization level when get workspace * fixup * Update regex and add unit tests * Add persist error toast for prebuild errors * 💄 * Fix stopped workspace log * fix rerun * Ensure fga enabled like papi * Update components/dashboard/src/prebuilds/detail/PrebuildDetailPage.tsx Co-authored-by: Filip Troníček <[email protected]> * Address feedback --------- Co-authored-by: Filip Troníček <[email protected]>
- Loading branch information
1 parent
c13409e
commit bcd2e93
Showing
9 changed files
with
224 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
components/public-api/typescript-common/src/prebuild-utils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Copyright (c) 2024 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { expect } from "chai"; | ||
import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; | ||
import { getPrebuildErrorMessage, matchPrebuildError } from "./prebuild-utils"; | ||
|
||
describe("PrebuildUtils", () => { | ||
describe("PrebuildErrorMessage", () => { | ||
it("Application Error", async () => { | ||
const errorList = [ | ||
new ApplicationError(ErrorCodes.UNIMPLEMENTED, "not implemented"), | ||
new ApplicationError(ErrorCodes.INTERNAL_SERVER_ERROR, "not implemented#"), | ||
new ApplicationError(ErrorCodes.NOT_FOUND, "#not implemented#"), | ||
new ApplicationError(ErrorCodes.NOT_FOUND, "#not#implemented#"), | ||
new ApplicationError(ErrorCodes.NOT_FOUND, "12312#not#implemented#"), | ||
]; | ||
for (const err of errorList) { | ||
const msg = getPrebuildErrorMessage(err); | ||
const result = matchPrebuildError(msg); | ||
expect(result).to.not.undefined; | ||
expect(result?.code).to.equal(err.code); | ||
expect(result?.message).to.equal(err.message); | ||
} | ||
}); | ||
|
||
it("Error", async () => { | ||
const errorList = [ | ||
new Error("not implemented"), | ||
new Error("not implemented#"), | ||
new Error("#not implemented#"), | ||
new Error("#not#implemented#"), | ||
new Error("12312#not#implemented#"), | ||
]; | ||
for (const err of errorList) { | ||
const msg = getPrebuildErrorMessage(err); | ||
const result = matchPrebuildError(msg); | ||
expect(result).to.not.undefined; | ||
expect(result?.code).to.equal(ErrorCodes.INTERNAL_SERVER_ERROR); | ||
expect(result?.message).to.equal("unexpected error"); | ||
} | ||
}); | ||
|
||
it("others", async () => { | ||
const errorList = [{}, [], Symbol("hello")]; | ||
for (const err of errorList) { | ||
const msg = getPrebuildErrorMessage(err); | ||
const result = matchPrebuildError(msg); | ||
expect(result).to.not.undefined; | ||
expect(result?.code).to.equal(ErrorCodes.INTERNAL_SERVER_ERROR); | ||
expect(result?.message).to.equal("unknown error"); | ||
} | ||
}); | ||
}); | ||
|
||
describe("matchPrebuildError", () => { | ||
it("happy path", async () => { | ||
const result = matchPrebuildError( | ||
"X-Prebuild-Error#404#Headless logs for 07f877b5-631c-47c8-82aa-09de2f11fff3 not found#X-Prebuild-Error", | ||
); | ||
expect(result).to.not.undefined; | ||
expect(result?.code).to.be.equal(404); | ||
expect(result?.message).to.be.equal("Headless logs for 07f877b5-631c-47c8-82aa-09de2f11fff3 not found"); | ||
}); | ||
|
||
it("not match", async () => { | ||
const result = matchPrebuildError("echo hello"); | ||
expect(result).to.be.undefined; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.