Skip to content

Commit 9479f9e

Browse files
committed
fix: body parser error interceptor
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 93824fe commit 9479f9e

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

backend/src/api/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ setImmediate(async () => {
147147

148148
app.use(bodyParser.urlencoded({ limit: '5mb', extended: true }))
149149

150+
app.use((err: any, _: any, res: any, next: any) => {
151+
if (err.type === 'entity.parse.failed') {
152+
res.status(400).json({ error: { code: 'BAD_REQUEST', message: 'Invalid JSON body' } })
153+
return
154+
}
155+
next(err)
156+
})
157+
150158
app.use((req, res, next) => {
151159
// @ts-ignore
152160
req.userData = {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ function buildTimeline(
406406
// ─── Per-member resolution ────────────────────────────────────────────────────
407407

408408
function resolveAffiliationsForMember(memberId: string, rows: IWorkRow[]): IAffiliationPeriod[] {
409-
410409
// If one undated work-experience org is marked primary, drop other undated work-experience orgs
411410
// to avoid infinite conflicts. Manual affiliations (segmentId !== null) are never dropped.
412411
const primaryUndated = rows.find((r) => r.isPrimaryWorkExperience && !r.dateStart && !r.dateEnd)

0 commit comments

Comments
 (0)