Skip to content

Commit 1b7c7b5

Browse files
authored
fix: error logs missing error text (#7071)
1 parent 9a5b8e4 commit 1b7c7b5

File tree

10 files changed

+103
-18
lines changed

10 files changed

+103
-18
lines changed

.changeset/tangy-ravens-love.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive': patch
3+
---
4+
5+
fix error printing in logs

packages/services/api/src/modules/alerts/providers/adapters/msteams.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ export class TeamsCommunicationAdapter implements CommunicationAdapter {
7272
}),
7373
);
7474
} catch (error) {
75-
this.logger.error(`Failed to send Microsoft Teams notification`, error);
75+
const errorText =
76+
error instanceof Error
77+
? error.toString()
78+
: typeof error === 'string'
79+
? error
80+
: JSON.stringify(error);
81+
this.logger.error(`Failed to send Microsoft Teams notification (error=%s)`, errorText);
7682
}
7783
}
7884

@@ -108,7 +114,13 @@ export class TeamsCommunicationAdapter implements CommunicationAdapter {
108114

109115
await this.sendTeamsMessage(webhookUrl, message);
110116
} catch (error) {
111-
this.logger.error(`Failed to send Microsoft Teams notification`, error);
117+
const errorText =
118+
error instanceof Error
119+
? error.toString()
120+
: typeof error === 'string'
121+
? error
122+
: JSON.stringify(error);
123+
this.logger.error(`Failed to send Microsoft Teams notification`, errorText);
112124
}
113125
}
114126

packages/services/api/src/modules/alerts/providers/adapters/slack.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,13 @@ export class SlackCommunicationAdapter implements CommunicationAdapter {
146146
err.statusCode,
147147
);
148148
} else {
149-
this.logger.error(`Failed to send Slack notification (message=%s)`, err.message);
149+
const errorText =
150+
error instanceof Error
151+
? error.toString()
152+
: typeof error === 'string'
153+
? error
154+
: JSON.stringify(error);
155+
this.logger.error(`Failed to send Slack notification (message=%s)`, errorText);
150156
}
151157
}
152158
}

packages/services/api/src/modules/alerts/providers/adapters/webhook.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ export class WebhookCommunicationAdapter implements CommunicationAdapter {
4747
event: input.event,
4848
});
4949
} catch (error) {
50-
this.logger.error(`Failed to send Webhook notification`, error);
50+
const errorText =
51+
error instanceof Error
52+
? error.toString()
53+
: typeof error === 'string'
54+
? error
55+
: JSON.stringify(error);
56+
this.logger.error(`Failed to send Webhook notification`, errorText);
5157
}
5258
}
5359

packages/services/api/src/modules/app-deployments/providers/persisted-document-scheduler.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ export class PersistedDocumentScheduler {
3636
const tasks = new Map<string, PendingTaskRecord>();
3737

3838
worker.on('error', error => {
39-
console.error(error);
40-
this.logger.error('Worker error %s', error);
39+
const errorText =
40+
error instanceof Error
41+
? error.toString()
42+
: typeof error === 'string'
43+
? error
44+
: JSON.stringify(error);
45+
this.logger.error('Worker error (error=%s)', errorText);
4146
});
4247

4348
worker.on('exit', code => {

packages/services/api/src/modules/audit-logs/providers/audit-log-recorder.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ export class AuditLogRecorder {
8989
queryId: 'create-audit-log',
9090
});
9191
} catch (error) {
92-
this.logger.error('Failed to create audit log event', error);
92+
const errorText =
93+
error instanceof Error
94+
? error.toString()
95+
: typeof error === 'string'
96+
? error
97+
: JSON.stringify(error);
98+
this.logger.error('Failed to create audit log event (error=%s)', errorText);
9399
captureException(error, {
94100
extra: {
95101
data,

packages/services/api/src/modules/integrations/providers/github-integration-manager.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,19 @@ export class GitHubIntegrationManager {
303303
},
304304
};
305305
} catch (error) {
306-
this.logger.error('Failed to create check-run', error);
306+
const errorText =
307+
error instanceof Error
308+
? error.toString()
309+
: typeof error === 'string'
310+
? error
311+
: JSON.stringify(error);
312+
this.logger.error(
313+
'Failed to create check-run (owner=%s, name=%s, sha=%s, error=%s)',
314+
input.repositoryOwner,
315+
input.repositoryName,
316+
input.sha,
317+
errorText,
318+
);
307319

308320
if (isOctokitRequestError(error)) {
309321
this.logger.debug(
@@ -447,7 +459,19 @@ export class GitHubIntegrationManager {
447459
url: result.data.url,
448460
} as const;
449461
} catch (error) {
450-
this.logger.error('Failed to update check-run', error);
462+
const errorText =
463+
error instanceof Error
464+
? error.toString()
465+
: typeof error === 'string'
466+
? error
467+
: JSON.stringify(error);
468+
this.logger.error(
469+
'Failed to update check-run (owner=%s, name=%s, checkId=%s, error=%s)',
470+
args.checkRun.owner,
471+
args.checkRun.repository,
472+
args.checkRun.checkRunId,
473+
errorText,
474+
);
451475

452476
if (isOctokitRequestError(error)) {
453477
this.logger.debug(

packages/services/api/src/modules/schema/providers/schema-publisher.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ export class SchemaPublisher {
230230
failDiffOnDangerousChange: settings.failDiffOnDangerousChange,
231231
};
232232
} catch (error: unknown) {
233-
this.logger.error(`Failed to get settings`, error);
233+
const errorText =
234+
error instanceof Error
235+
? error.toString()
236+
: typeof error === 'string'
237+
? error
238+
: JSON.stringify(error);
239+
this.logger.error(`Failed to get settings (error=%s)`, errorText);
234240
throw error;
235241
}
236242
}
@@ -2019,8 +2025,14 @@ export class SchemaPublisher {
20192025
errors,
20202026
initial,
20212027
})
2022-
.catch(err => {
2023-
this.logger.error('Failed to trigger schema change notifications', err);
2028+
.catch(error => {
2029+
const errorText =
2030+
error instanceof Error
2031+
? error.toString()
2032+
: typeof error === 'string'
2033+
? error
2034+
: JSON.stringify(error);
2035+
this.logger.error('Failed to trigger schema change notifications (error=%s)', errorText);
20242036
});
20252037
}
20262038

packages/services/api/src/modules/token/providers/token-storage.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,14 @@ export class TokenStorage {
118118

119119
return tokenInfo;
120120
} catch (error: any) {
121-
if (!(error instanceof HiveError)) {
122-
this.logger.error(error);
123-
}
124-
125-
this.logger.error('Failed to fetch token', error);
121+
const errorText =
122+
error instanceof Error
123+
? error.toString()
124+
: typeof error === 'string'
125+
? error
126+
: JSON.stringify(error);
127+
128+
this.logger.error('Failed to fetch token (error=%s)', errorText);
126129
throw new HiveError('Invalid token provided', {
127130
originalError: error,
128131
});

packages/services/schema/src/composition-scheduler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ export class CompositionScheduler {
104104

105105
// catch uncaught exception from worker thread. Worker thread gets terminated.
106106
worker.on('error', error => {
107-
this.logger.error('Worker error %s', error);
107+
const errorText =
108+
error instanceof Error
109+
? error.toString()
110+
: typeof error === 'string'
111+
? error
112+
: JSON.stringify(error);
113+
this.logger.error('Worker error (error=%s)', errorText);
108114
Sentry.captureException(error, {
109115
extra: {
110116
requestId: workerState?.args.requestId ?? '',

0 commit comments

Comments
 (0)