Skip to content

Commit 49ea594

Browse files
authored
fix: removed the detail section because it's not helpful (#4005)
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent a9cde48 commit 49ea594

2 files changed

Lines changed: 32 additions & 17 deletions

File tree

services/apps/cron_service/src/jobs/integrationResultsReporting.job.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ interface IResultStateCount {
2020
interface IErrorGroup {
2121
errorMessage: string
2222
location: string
23-
message: string
2423
count: number
2524
avgRetries: number
2625
maxRetries: number
@@ -69,7 +68,6 @@ const job: IJobDefinition = {
6968
SELECT
7069
COALESCE(r.error->>'errorMessage', '[no errorMessage]') AS "errorMessage",
7170
COALESCE(r.error->>'location', '[no location]') AS location,
72-
COALESCE(r.error->>'message', '[no message]') AS message,
7371
count(*)::int AS count,
7472
round(avg(r.retries), 1)::float AS "avgRetries",
7573
max(r.retries)::int AS "maxRetries",
@@ -81,8 +79,7 @@ const job: IJobDefinition = {
8179
WHERE r.state = 'error'
8280
GROUP BY
8381
r.error->>'errorMessage',
84-
r.error->>'location',
85-
r.error->>'message'
82+
r.error->>'location'
8683
ORDER BY count DESC
8784
LIMIT 20
8885
`,
@@ -125,7 +122,6 @@ const job: IJobDefinition = {
125122
`• *${group.count}x* \`${group.errorMessage}\``,
126123
` _Location:_ \`${group.location}\` | _retries avg/max:_ ${group.avgRetries}/${group.maxRetries}${group.platforms ? ` | _platforms:_ \`${group.platforms}\`` : ''}`,
127124
` _Age:_ ${ageLabel}`,
128-
` _Detail:_ ${group.message}`,
129125
'',
130126
)
131127
}

services/apps/data_sink_worker/src/service/dataSink.service.ts

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,35 @@ import MemberService from './member.service'
3535

3636
/* eslint-disable @typescript-eslint/no-explicit-any */
3737

38+
/**
39+
* Extracts the first app-code frame from an error's stack trace as the location.
40+
* Uses process.cwd() (the service root) to match only this service's own source
41+
* files, skipping node_modules and shared library frames.
42+
*/
43+
function extractLocationFromError(error: unknown): string {
44+
const stack = (error as any)?.stack
45+
if (!stack) return 'unknown'
46+
47+
const serviceDir = process.cwd()
48+
for (const line of (stack as string).split('\n')) {
49+
if (line.includes(serviceDir) && !line.includes('node_modules')) {
50+
// Named frame: "at [async] FunctionName (file:line:col)"
51+
const named = line.match(/at\s+(.+)\s+\((.+):(\d+):\d+\)/)
52+
if (named) {
53+
const file = named[2].replace(`${serviceDir}/`, '')
54+
return `${file}:${named[3]} (${named[1].trim()})`
55+
}
56+
// Anonymous frame: "at file:line:col"
57+
const anon = line.match(/at\s+\(?(.+):(\d+):\d+\)?/)
58+
if (anon) {
59+
return `${anon[1].replace(`${serviceDir}/`, '')}:${anon[2]}`
60+
}
61+
}
62+
}
63+
64+
return 'unknown'
65+
}
66+
3867
export default class DataSinkService extends LoggerBase {
3968
private readonly repo: DataSinkRepository
4069

@@ -55,15 +84,12 @@ export default class DataSinkService extends LoggerBase {
5584
private async triggerResultError(
5685
resultInfo: IResultData,
5786
resultExists: boolean,
58-
location: string,
59-
message: string,
6087
error: any,
6188
metadata?: Record<string, unknown>,
6289
): Promise<void> {
6390
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6491
const errorData: any = {
65-
location,
66-
message,
92+
location: extractLocationFromError(error),
6793

6894
metadata,
6995

@@ -463,14 +489,7 @@ export default class DataSinkService extends LoggerBase {
463489
if (!result.success) {
464490
const resultInfo = single(results, (r) => r.id === resultId)
465491

466-
await this.triggerResultError(
467-
resultInfo,
468-
batchEntry.created,
469-
'process-result',
470-
'Error processing result.',
471-
result.err,
472-
result.metadata,
473-
)
492+
await this.triggerResultError(resultInfo, batchEntry.created, result.err, result.metadata)
474493

475494
errors++
476495
} else {

0 commit comments

Comments
 (0)