Skip to content

Commit

Permalink
api: Log the full pull payload for debugging (#2151)
Browse files Browse the repository at this point in the history
* api: Log the full pull payload for debugging

* api/stream: Log payload after it's compatible with stream schema

* typo
  • Loading branch information
victorges authored Apr 29, 2024
1 parent a4a1767 commit 0ba6c69
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/api/src/controllers/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`],
Expand All @@ -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({
Expand Down Expand Up @@ -1096,6 +1105,7 @@ app.put(
}
const streamExisted = streams.length === 1;

const ingest = await getIngestBase(req);
const { pullUrl, pullRegion } = await resolvePullUrlAndRegion(
rawPayload,
ingest
Expand Down

0 comments on commit 0ba6c69

Please sign in to comment.