Skip to content

Commit 1ace384

Browse files
committed
Add more helpful error messaging to handleAuth
1 parent 4964327 commit 1ace384

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/integration-tests/AuthorizationClient.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
describe("AuthorizationClient", () => {
1616
jest.setTimeout(60000);
1717

18-
const clientPromise = orkesConductorClient();
1918
const suffix = Date.now();
2019

2120
let authClient: AuthorizationClient;
@@ -31,8 +30,19 @@ describe("AuthorizationClient", () => {
3130
const groupsToCleanup: string[] = [];
3231

3332
beforeAll(async () => {
34-
const client = await clientPromise;
35-
const clients = new OrkesClients(client);
33+
// Retry client creation to handle transient auth failures in CI
34+
const maxAttempts = 3;
35+
let client;
36+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
37+
try {
38+
client = await orkesConductorClient();
39+
break;
40+
} catch (e) {
41+
if (attempt === maxAttempts) throw e;
42+
await new Promise((r) => setTimeout(r, 2000 * attempt));
43+
}
44+
}
45+
const clients = new OrkesClients(client!);
3646
authClient = clients.getAuthorizationClient();
3747
metadataClient = clients.getMetadataClient();
3848

@@ -57,6 +67,8 @@ describe("AuthorizationClient", () => {
5767
});
5868

5969
afterAll(async () => {
70+
// Skip cleanup if beforeAll failed (e.g. auth error in CI) and clients were never set
71+
if (!authClient || !metadataClient) return;
6072
// Cleanup groups first (they reference users)
6173
for (const gid of groupsToCleanup) {
6274
try {

src/sdk/createConductorClient/helpers/handleAuth.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,14 @@ export const handleAuth = async (
5454
logger?.debug(`Auth error code from server: ${errorCode}`);
5555
}
5656

57+
const statusHint =
58+
response?.status != null ? ` (HTTP ${response.status})` : "";
5759
const message =
5860
error && typeof error === "object" && "message" in error
59-
? String((error as { message: unknown }).message)
60-
: "Unknown error";
61+
? String((error as { message: unknown }).message) + statusHint
62+
: error && typeof error === "object" && "error" in error
63+
? String((error as { error: unknown }).error) + statusHint
64+
: `Unknown error${statusHint}`;
6165
throw new ConductorSdkError(
6266
`Failed to generate authorization token: ${message}`,
6367
error instanceof Error ? error : undefined

0 commit comments

Comments
 (0)