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(logs): truncate only non required properties #2751

Merged
merged 4 commits into from
Sep 20, 2024

Conversation

bodinsamuel
Copy link
Collaborator

Describe your changes

Fixes https://linear.app/nango/issue/NAN-1769/logs-truncation-removes-mandatory-fields

  • Only truncate meta object
    When truncating a log's JSON it would randomly remove mandatory properties if it was too big. Now we truncate only selected property, it's not yet bulletproof because people could send a large message and large meta object too. We should limit the message size

@bodinsamuel bodinsamuel self-assigned this Sep 20, 2024
Copy link

linear bot commented Sep 20, 2024

activityLogId: this.activityLogId,
log: { ...log, meta: truncateJson(log.meta) as MessageRowInsert['meta'] }
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we also truncate request and response?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mmh I didn't think about that indeed. It's annoying because truncating a json object is really slow, I wish we had a way to do path traversal and determine length without having to stringify each node.
Let's see if we need after this PR

@bodinsamuel bodinsamuel merged commit 280be08 into master Sep 20, 2024
22 checks passed
@bodinsamuel bodinsamuel deleted the fix/logs-correctly-truncate-json branch September 20, 2024 15:59
hassan254-prog pushed a commit that referenced this pull request Sep 25, 2024
## Describe your changes

Fixes
https://linear.app/nango/issue/NAN-1769/logs-truncation-removes-mandatory-fields

- Only truncate `meta` object
When truncating a log's JSON it would randomly remove mandatory
properties if it was too big. Now we truncate only selected property,
it's not yet bulletproof because people could send a large message and
large `meta` object too. We should limit the message size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants