From 0ba6c691238bbc34b814e488cd4ac40e7302f557 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Mon, 29 Apr 2024 11:43:59 -0300 Subject: [PATCH] api: Log the full pull payload for debugging (#2151) * api: Log the full pull payload for debugging * api/stream: Log payload after it's compatible with stream schema * typo --- packages/api/src/controllers/stream.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/api/src/controllers/stream.ts b/packages/api/src/controllers/stream.ts index 2bcd8a7aa1..f8e05b70b2 100644 --- a/packages/api/src/controllers/stream.ts +++ b/packages/api/src/controllers/stream.ts @@ -1046,11 +1046,6 @@ app.put( async (req, res) => { const { key = "pull.source", waitActive } = toStringValues(req.query); const rawPayload = req.body as NewStreamPayload; - - logger.info(`pull request received for stream name=${rawPayload.name}`); - - const ingest = await getIngestBase(req); - if (!rawPayload.pull) { return res.status(400).json({ errors: [`stream pull configuration is required`], @@ -1064,6 +1059,20 @@ app.put( creatorId: mapInputCreatorId(rawPayload.creatorId), }; + const payloadLog = { + ...db.stream.cleanWriteOnlyResponse(payload as DBStream), + pull: { + ...payload.pull, + source: "REDACTED", + headers: "REDACTED", + headersList: Object.keys(payload.pull.headers || {}), + }, + }; + logger.info( + `pull request received userId=${req.user.id} ` + + `payload=${JSON.stringify(JSON.stringify(payloadLog))}` // double stringify to escape string for logfmt + ); + const keyValue = _.get(payload, pullStreamKeyAccessors[key]); if (!keyValue) { return res.status(400).json({ @@ -1096,6 +1105,7 @@ app.put( } const streamExisted = streams.length === 1; + const ingest = await getIngestBase(req); const { pullUrl, pullRegion } = await resolvePullUrlAndRegion( rawPayload, ingest