fix: clear stale parsed cache on observation packets#505
Merged
Kpa-clawbot merged 2 commits intomasterfrom Apr 3, 2026
Merged
Conversation
added 2 commits
April 3, 2026 02:39
…acket into observations After PR #400 cached JSON.parse results as _parsedPath/_parsedDecoded on packet objects, object spreads that create observation packets from parent packets inadvertently copied the stale cache. This caused getParsedPath()/getParsedDecoded() to return the parent's cached values instead of re-parsing from the observation's own path_json/decoded_json. Delete _parsedPath and _parsedDecoded after every spread site that creates observation packets (5 locations in packets.js), forcing re-parse from the observation's own data. Fixes #504
The same delete _parsedPath/_parsedDecoded pattern was repeated at all 5 spread sites in packets.js. Extract into a shared clearParsedCache() function in packet-helpers.js that: - Deletes both cached properties - Returns the object for inline use in map callbacks - Is documented with the cache poisoning context (issue #504) Also adds a dedicated test for clearParsedCache and updates existing tests to use the helper instead of manual delete.
Kpa-clawbot
commented
Apr 3, 2026
Owner
Author
Kpa-clawbot
left a comment
There was a problem hiding this comment.
Independent review
Verdict: Approve ✅
Clean, well-scoped fix. The root cause analysis is correct — object spread copies the _parsedPath/_parsedDecoded cache properties from the parent, causing all observation packets to display the parent's path.
What's good:
- Extracting
clearParsedCache()into a shared helper inpacket-helpers.jsrather than inliningdeleteat each site — DRY and consistent - Helper returns the object, enabling inline use in
.map()chains (lines 502, 838, 1981) — clean ergonomics - All 5 spread sites identified and patched
- Tests exercise the actual
packet-helpers.jsmodule viavm.createContext(not copies) — consistent with codebase conventions - Tests cover both cache clearing mechanics and the end-to-end spread-clear-reparse flow
No must-fix items found. The change is minimal, correct, and well-tested.
This was referenced Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #504 — Expanding a packet in the packets UI showed the same path on every observation instead of each observation's unique path.
Root Cause
PR #400 (fixing #387) added caching of
JSON.parseresults as_parsedPathand_parsedDecodedproperties on packet objects. When observation packets are created via object spread ({...parentPacket, ...obs}), these cache properties are copied from the parent. Subsequent calls togetParsedPath(obsPacket)hit the stale cache and return the parent's path, ignoring the observation's ownpath_json.Fix
After every object spread that creates an observation packet from a parent packet, delete the cache properties so they get re-parsed from the observation's own data:
Applied to all 5 spread sites in
public/packets.js:Tests
Added 2 new tests in
test-frontend-helpers.js:All 431 frontend helper tests pass. All 62 packet filter tests pass.