fix: add defensive checks for undefined values in diff handling#19261
Open
dongjiang1989 wants to merge 5 commits intoanomalyco:devfrom
Open
fix: add defensive checks for undefined values in diff handling#19261dongjiang1989 wants to merge 5 commits intoanomalyco:devfrom
dongjiang1989 wants to merge 5 commits intoanomalyco:devfrom
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #19221 - Why it's related: This PR appears to address the same core issue - adding defensive checks to prevent crashes when diffs are undefined or not arrays. PR #19221 specifically uses |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
6 tasks
efcddf0 to
882ed3f
Compare
1n4001
reviewed
Mar 26, 2026
dongjiang1989
commented
Mar 26, 2026
Dredok
added a commit
to Dredok/opencode
that referenced
this pull request
Mar 26, 2026
Prevents 'e.diffs.map is not a function' crash when session_diff data from the server is undefined or not an array. Guards added at: - event-reducer (incoming data validation) - session.tsx (diffs and turnDiffs memos) - session-side-panel.tsx (diffs memo) Ref: upstream issues anomalyco#19217, anomalyco#19262, PR anomalyco#19261
- Add nullish checks for diffs array to prevent 'map is not a function' error - Add nullish checks for path/directory parameters before replaceAll - Add Array.isArray validation for session_diff data - Add defensive checks for vcs.diff.git and vcs.diff.branch Fixes: anomalyco#19241, anomalyco#19222, anomalyco#19240, anomalyco#19217
a95acf0 to
de3b587
Compare
4 tasks
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
TypeError: e.diffs.map is not a functionreplaceAllto preventTypeError: Cannot read properties of undefined (reading 'replaceAll')Array.isArrayvalidation for session_diff data from APIIssue for this PR
Closes #19241
Closes #19222
Closes #19240
Closes #19217
Type of change
What does this PR do?
Please provide a description of the issue, the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR.
session-side-panel.tsx- Handle undefined/null diffs indiffFilesandkindsmemosreview-tab.tsx- Handle undefined diffs in effect and rendersession.tsx- Validate session_diff is array before usefile-tree.tsx- Add null check for path parameterdialog-select-directory.tsx- Add null check for inputlayout/helpers.ts- Add null check for directory parameterIf you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
How did you verify your code works?
bun typecheckpasses across all 13 packagesScreenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist