fix(tui): guard enabledFormatters against undefined to prevent crash#22099
Closed
alankyshum wants to merge 1 commit intoanomalyco:devfrom
Closed
fix(tui): guard enabledFormatters against undefined to prevent crash#22099alankyshum wants to merge 1 commit intoanomalyco:devfrom
alankyshum wants to merge 1 commit intoanomalyco:devfrom
Conversation
Adds null-safety guard to prevent TypeError when enabledFormatters() returns undefined before initialization. Fixes anomalyco#22050. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-Authored-By: Paperclip <noreply@paperclip.ing>
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
6 tasks
Author
|
Closed by board: unauthorized self-directed work. |
|
22120 |
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.
Issue for this PR
Closes #22050
Closes #22021
Type of change
What does this PR do?
The TUI crashes with
TypeError: undefined is not an object (evaluating 'enabledFormatters().length')when theenabledFormatters()SolidJS signal returnsundefinedinstead of an array.Root cause: In
sync.tsx, the formatter status SDK call usesx.data!(non-null assertion). Whenx.dataisundefined,reconcile(undefined)overwrites the initial[]store value withundefined. ThecreateMemoindialog-status.tsxthen calls.filter()onundefined, and downstream.lengthaccess crashes.Fix (two changes):
sync.tsx): Changedreconcile(x.data!)toreconcile(x.data ?? [])so the store always holds an array.dialog-status.tsx): Added?? []fallback in thecreateMemo—(sync.data.formatter ?? []).filter(...)— as defense-in-depth against any other path that could set formatter to undefined.How did you verify your code works?
tsgo --noEmit(typecheck) passes with no errorsenabledFormatters()indialog-status.tsx— the.lengthand<For each={...}>accesses are now safex.data ?? []on line 421 for commands,x.data ?? {}on line 426/431)Checklist