Repository navigation
fix: cap the total size of activity attributes - #4981
Conversation
Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
PR SummaryMedium Risk Overview Payloads under the cap serialize the same as before; larger ones go through
Reviewed by Cursor Bugbot for commit 527268a. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🔵 Needs a closer look
Lossy pruning changes shared ingestion behavior across all platforms and warrants code-owner validation.
0 open findings
What changed in this PR
Adds a 16 KiB total limit to serialized activity attributes across all platforms, extending the existing per-string trimming.
Changes:
- Prunes oversized attributes deterministically, shrinking nested containers while preserving smaller values where possible.
- Logs pruning events with activity metadata, without attribute contents.
- Adds tests for size limits, pruning order, nested structures, UTF-8 sizing, and randomized inputs.
| File | Description |
|---|---|
| services/libs/data-access-layer/src/activities/insert.ts | Implements capped serialization, recursive pruning, and warnings. |
| services/libs/data-access-layer/src/activities/insert.test.ts | Tests serialization compatibility and pruning behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary
Caps the serialized size of an activity's attributes at 16 KiB for every platform. Since #4934 each string is trimmed to 500 characters, but an activity with many attributes or long arrays could still be arbitrarily large in total. Activities under the cap are serialized exactly as before; larger ones lose their largest values first instead of everything.
Changes
serializeAttributesreplacesobjectToBytes: the existing 500-character string trim, then a UTF-8 byte measurement againstATTRIBUTES_MAX_BYTES(16 KiB, which keeps a 10-message Kafka batch far below the 1 MB broker default). Under the cap the output is unchanged.pruneToFitremoves the largest entries first: objects and arrays shrink from the inside, other values are dropped. Ties go alphabetically for keys and from the end for array items, so the output is deterministic. Small scalars that pipes read, likeisIndirectFork, are the last to go.Type of change
Related issue
Refs linuxfoundation/lfx-cdp-insights-ops#748