fix(buglog): make bug search null-safe across schema drift#44
Open
GordongWang wants to merge 1 commit into
Open
fix(buglog): make bug search null-safe across schema drift#44GordongWang wants to merge 1 commit into
bug search null-safe across schema drift#44GordongWang wants to merge 1 commit into
Conversation
searchBugs assumed every entry has non-null error_message/root_cause/fix/ tags/file. A single entry missing any of these (older entries omit file/ tags; some tooling writes a `files` array instead of singular `file`) made b.file.toLowerCase() / b.tags.some() throw, aborting the ENTIRE search. - Guard every field access (typeof string / Array.isArray) so a missing field on one entry skips it instead of crashing the whole search. - Also search the `files` array (added files?: string[] to BugEntry) and make `file` optional to match real-world buglogs. Verified: tsc --noEmit 0 errors; functional test over a mixed-schema buglog (missing file / files array / normal) — no crash, correct matches.
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.
Problem
openwolf bug search <term>crashes with aTypeErroron any buglog that contains an entry missing one of the fieldssearchBugsassumes are always present:searchBugsdoesb.error_message.toLowerCase(),b.tags.some(...),b.file.toLowerCase()etc. with no null-guard. Real-world buglogs drift over time:fileand/ortags.files: string[]array instead of a singularfile.A single such entry anywhere in the array makes the
.filter()callback throw, which aborts the entire search — so one legacy entry breaksbug searchfor the whole project. (Hit this on a 1900+ entry buglog where ~28audit-finding-*entries had nofilekey.)Fix
Make the search field-access null-safe and tolerant of the
filesarray:has(s)helper (typeof s === "string" && …) andhasAny(a)(Array.isArray(a) && a.some(has)) so a missing/wrong-typed field on one entry skips that entry instead of crashing the whole search.filesarray; addedfiles?: string[]toBugEntryand madefileoptional to match real-world data.No behavioural change for well-formed entries; only previously-crashing inputs now search cleanly.
Verification
pnpm exec tsc --noEmit→ 0 errors.file, one with afilesarray, one normal):search "legacy"→ matches the missing-fileentry (previously crashed) ✓search "<a files path>"→ matches via thefilesarray ✓search "<a file path>"→ matches via singularfile✓🤖 Generated with Claude Code