
If initialExampleId is invalid or not found in demoItems, demoItems.find will return undefined. The non-null assertion ! will bypass TypeScript compilation checks, but at runtime, accessing selectedItem.messages will throw a TypeError: Cannot read properties of undefined (reading 'messages') and crash the application.
To prevent this, we should safely fall back to the first demo item (demoItems[0]) if the specified ID is not found, and use optional chaining for the initial state.
const [selectedExampleId, setSelectedExampleId] = useState(initialExampleId ?? demoItems[0]?.id);
const selectedItem = demoItems.find(e => e.id === selectedExampleId) ?? demoItems[0];
Originally posted by @gemini-code-assist[bot] in https://github.com/a2ui-project/a2ui/pull/1607#discussion_r3392900107
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues
Once completed please upload the output files to this GitHub issue.
See Collect WSL logs (recommended method).
If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.
Abuse reported.