Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(keystone): INFRA-296 move gql related logging to pino auto-loggin… #4727

Closed
wants to merge 1 commit into from

Conversation

sitozzz
Copy link
Member

@sitozzz sitozzz commented May 14, 2024

…g context

Copy link

sonarcloud bot commented May 14, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@@ -1,6 +1,7 @@
const serializers = require('pino-std-serializers')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should it in package.json of keystone package

Copy link
Member Author

@sitozzz sitozzz May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll do it right here

@@ -14,6 +15,12 @@ function getKeystonePinoOptions () {
customProps: (req, res) => {
return getReqLoggerContext(req)
},
serializers: {
res: (res) => {
const errors = res.raw.req.errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be wrapped with get or optional chain in case of no errors or smth like this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, sounds reasonable

serializers: {
res: (res) => {
const errors = res.raw.req.errors
return { gqlErrors: errors, ...serializers.req(res) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, is it correct behaviour? (You're overriding serializers.res, but using .req here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct. It was done for security reasons (hide body of the logged response)

@@ -35,7 +49,7 @@ function getReqLoggerContext (req) {
}
}

return { reqId, sessionId, user, ip, fingerprint, complexity }
return omitBy({ reqId, sessionId, user, ip, fingerprint, complexity, operationName, variables, query, operationId }, isNil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is omitting previously existing properties on object safe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What did you mean? That op is just filtering out empty values of the resulting log output

@sitozzz sitozzz closed this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants