Repository navigation
fix: stop unwrapping activity attributes once they are no longer a string - #4980
Conversation
…ring Attributes that are a JSON-encoded number or boolean made the unwrap loop parse the same value forever and hang the data sink worker. Any value that doesn't unwrap to an object is now stored as empty attributes. Refs linuxfoundation/lfx-cdp-insights-ops#814 Signed-off-by: Uroš Marolt <uros@marolt.me>
PR SummaryLow Risk Overview The loop now runs only while the value is still a string, then returns the object unchanged or The helper is exported and covered by new unit tests for objects, nested JSON encoding, and scalar encodings. Reviewed by Cursor Bugbot for commit e9eede9. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🔵 Needs a closer look
The protected shared data-access-layer change requires code-owner review.
0 open findings
What changed in this PR
Fixes an infinite loop in activity attribute decoding that could hang the data sink worker.
Changes:
- Parses attributes only while they remain strings, returning
{}for non-object results. - Adds regression tests for objects, nested encoding, and encoded scalar values.
| File | Description |
|---|---|
| services/libs/data-access-layer/src/activities/insert.ts | Bounds decoding by value type and normalizes non-object results. |
| services/libs/data-access-layer/src/activities/insert.test.ts | Adds attribute-decoding regression coverage. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…attributes-loop Signed-off-by: Uroš Marolt <uros@marolt.me> # Conflicts: # services/libs/data-access-layer/src/activities/insert.test.ts # services/libs/data-access-layer/src/activities/insert.ts
Summary
tryToUnwrapAttributesparsed activity attributes until it got an object. Attributes that arrive as a JSON-encoded number or boolean ("5","true") parse to a value that is never an object, so the loop ran forever and hung the data sink worker. It now stops once the value is no longer a string, and anything that doesn't unwrap to an object is stored as empty attributes.Changes
tryToUnwrapAttributeskeeps parsing only while the value is a string and returns{}for any non-object result. Objects and JSON-encoded objects (also double-encoded) unwrap as before, JSONnullstill ends up as{}, and a string that isn't valid JSON still throws, as before."5","true","null"and a JSON-encoded string.Type of change
Related issue
Closes linuxfoundation/lfx-cdp-insights-ops#814