fix: ignore non-object memory metadata#346
Conversation
|
Warning Review limit reached
More reviews will be available in 20 minutes and 35 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Vale review — PR #346Quality: Q4/5 sharp Finding: The fix is correct and narrow. Evidence:
Proof gaps / minor notes:
Verdict: Request changes are not warranted — the fix is correct, narrow, and tested for the reported failure. The minor gaps (missing linked issue, incomplete non-object test coverage) are suggestions, not blockers. Action: Approve-equivalent. The two minor suggestions above can be addressed or deferred at maintainer discretion. – Vale |
compoodment
left a comment
There was a problem hiding this comment.
Vale Review
Quality: Q5/5 — proven
Name: Fix: ignore non-object memory metadata
Evidence:
- Current upstream
parseMetadataJson()returns the rawJSON.parse()result. WhenmetadataJsondecodes tonull,undefined, a number, or a string, the caller accesses.collectionon it and throwsCannot read properties of null (reading 'collection'). - The fix adds a type guard:
if (parsed && typeof parsed === "object" && !Array.isArray(parsed))— non-objects fall through to the existingcatch/missing path and return{}. - Regression test covers
nullmetadata and confirms matching results still return.
Diff review:
src/memory-runtime.ts:parseMetadataJson()now validates the parsed value is a non-null, non-array object before returning. Malformed metadata gets best-effort{}. Clean, narrow, no side effects.test/unit/memory-runtime.test.ts: New test "memory runtime bridge treats non-object metadata JSON as missing" withmetadataJson: new TextEncoder().encode("null"). Confirms result count and snippet survive. Good.
Overlaps with PR #342: PR #342 also handles parseGrepMetadata() returning null/non-object in the grep path. PR #346 fixes the broader parseMetadataJson() in the search-result path. These are complementary — #342 covers grep metadata, #346 covers search-result metadata. Both should merge.
Verdict: Approve. Narrow, proven, tested, no blast radius.
– Vale
Summary
metadataJsonvalues in the memory runtime bridge as missing metadata.nullmetadata so matching memory search results still return instead of throwing.Quality:
Q5 provenEvidence:
Cannot read properties of null (reading 'collection')whenmetadataJsondecodes to JSONnull.test/unit/memory-runtime.test.tsbefore the fix.parseMetadataJson()and preserves malformed metadata as best-effort{}.Scope:
metadataJson.Verification
Regression proof before fix:
After fix:
– Vale