Skip to content

Commit 2e5a4f4

Browse files
committed
fix: reduce log, simplify serializing error
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 750041c commit 2e5a4f4

2 files changed

Lines changed: 8 additions & 34 deletions

File tree

backend/src/api/public/middlewares/errorHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const errorHandler: ErrorRequestHandler = (
3535
}
3636

3737
req.log.error(
38-
{ error, url: req.url, method: req.method, query: req.query, body: req.body },
38+
{ error: { name: error?.name, message: error?.message, stack: error?.stack }, url: req.url, method: req.method, query: req.query, body: req.body },
3939
'Unhandled error in public API',
4040
)
4141

services/libs/data-access-layer/src/affiliations/index.ts

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function buildTimeline(
262262
const boundaryDate = boundaries[i]
263263
const activeOrgsAtBoundary = orgsActiveAt(allRows, boundaryDate)
264264

265-
log.info(
265+
log.debug(
266266
{
267267
memberId,
268268
boundaryDate: boundaryDate.toISOString(),
@@ -294,7 +294,7 @@ function buildTimeline(
294294

295295
if (uncoveredPeriodStart === null) {
296296
uncoveredPeriodStart = boundaryDate
297-
log.info(
297+
log.debug(
298298
{ memberId, uncoveredPeriodStart: boundaryDate.toISOString() },
299299
'uncovered period started',
300300
)
@@ -305,7 +305,7 @@ function buildTimeline(
305305

306306
// Orgs are active again — close the uncovered period using the fallback org if available
307307
if (uncoveredPeriodStart !== null) {
308-
log.info(
308+
log.debug(
309309
{
310310
memberId,
311311
fallbackOrg: fallbackOrg?.organizationName ?? null,
@@ -332,7 +332,7 @@ function buildTimeline(
332332

333333
// No current window open — start a new one with the winning org
334334
if (!currentOrg) {
335-
log.info(
335+
log.debug(
336336
{ memberId, org: winningAffiliation.organizationName, from: boundaryDate.toISOString() },
337337
'opening affiliation window',
338338
)
@@ -343,7 +343,7 @@ function buildTimeline(
343343

344344
// Winning org changed — close the current window and open a new one
345345
if (currentOrg.organizationId !== winningAffiliation.organizationId) {
346-
log.info(
346+
log.debug(
347347
{
348348
memberId,
349349
from: currentOrg.organizationName,
@@ -367,7 +367,7 @@ function buildTimeline(
367367
// Close the last open window using the org's actual end date (null = ongoing)
368368
if (currentOrg && currentWindowStart) {
369369
const endDate = currentOrg.dateEnd ? new Date(currentOrg.dateEnd).toISOString() : null
370-
log.info(
370+
log.debug(
371371
{
372372
memberId,
373373
org: currentOrg.organizationName,
@@ -385,7 +385,7 @@ function buildTimeline(
385385

386386
// Close a trailing uncovered period using the fallback org (ongoing, no end date)
387387
if (uncoveredPeriodStart !== null && fallbackOrg) {
388-
log.info(
388+
log.debug(
389389
{
390390
memberId,
391391
fallbackOrg: fallbackOrg.organizationName,
@@ -406,21 +406,6 @@ function buildTimeline(
406406
// ─── Per-member resolution ────────────────────────────────────────────────────
407407

408408
function resolveAffiliationsForMember(memberId: string, rows: IWorkRow[]): IAffiliationPeriod[] {
409-
log.debug(
410-
{
411-
memberId,
412-
totalRows: rows.length,
413-
rows: rows.map((r) => ({
414-
org: r.organizationName,
415-
dateStart: r.dateStart,
416-
dateEnd: r.dateEnd,
417-
isPrimary: r.isPrimaryWorkExperience,
418-
memberCount: r.memberCount,
419-
isManual: r.segmentId !== null,
420-
})),
421-
},
422-
'resolving affiliations',
423-
)
424409

425410
// If one undated work-experience org is marked primary, drop other undated work-experience orgs
426411
// to avoid infinite conflicts. Manual affiliations (segmentId !== null) are never dropped.
@@ -429,17 +414,6 @@ function resolveAffiliationsForMember(memberId: string, rows: IWorkRow[]): IAffi
429414
? rows.filter((r) => r.segmentId !== null || r.dateStart || r.id === primaryUndated.id)
430415
: rows
431416

432-
if (cleaned.length < rows.length) {
433-
log.debug(
434-
{
435-
memberId,
436-
dropped: rows.length - cleaned.length,
437-
keptPrimaryUndated: primaryUndated?.organizationName,
438-
},
439-
'dropped undated orgs (primary undated exists)',
440-
)
441-
}
442-
443417
const fallbackOrg = findFallbackOrg(cleaned)
444418
const datedRows = cleaned.filter((r) => r.dateStart)
445419

0 commit comments

Comments
 (0)