Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent Cody from crashing on init with mis-serialized chat history #3394

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

sqs
Copy link
Member

@sqs sqs commented Mar 13, 2024

Similar to #3367, this prevents Cody from crashing on initialization if the chat history contains vscode.Range JSON-serialized values (which are JSON-serialized as [start, end]). This is an easy and subtle bug to introduce, and it's valuable to protect against complete crashing on initialization.

The stack trace of the crash that this prevents is:

TypeError: Cannot read properties of undefined (reading 'line')
	at createDisplayTextWithFileLinks (/home/sqs/.vscode/extensions/sourcegraph.cody-ai-1.8.2/dist/extension.node.js:124081:56)
	at getDisplayText (/home/sqs/.vscode/extensions/sourcegraph.cody-ai-1.8.2/dist/extension.node.js:124292:12)
	at prepareChatMessage (/home/sqs/.vscode/extensions/sourcegraph.cody-ai-1.8.2/dist/extension.node.js:124279:18)
	at groupCodyChats (/home/sqs/.vscode/extensions/sourcegraph.cody-ai-1.8.2/dist/extension.node.js:124336:26)
...

I will backport this to the v1.8.0 branch to ensure that users can switch back to the release version safely if they were on the prerelease version (which has mis-serialized chat history at certain times).

Test plan

CI

Similar to #3367, this prevents Cody from crashing on initialization if the chat history contains `vscode.Range` JSON-serialized values (which are JSON-serialized as `[start, end]`). This is an easy and subtle bug to introduce, and it's valuable to protect against complete crashing on initialization.

The stack trace of the crash that this prevents is:

```
TypeError: Cannot read properties of undefined (reading 'line')
	at createDisplayTextWithFileLinks (/home/sqs/.vscode/extensions/sourcegraph.cody-ai-1.8.2/dist/extension.node.js:124081:56)
	at getDisplayText (/home/sqs/.vscode/extensions/sourcegraph.cody-ai-1.8.2/dist/extension.node.js:124292:12)
	at prepareChatMessage (/home/sqs/.vscode/extensions/sourcegraph.cody-ai-1.8.2/dist/extension.node.js:124279:18)
	at groupCodyChats (/home/sqs/.vscode/extensions/sourcegraph.cody-ai-1.8.2/dist/extension.node.js:124336:26)
...
```
@sqs sqs requested a review from a team March 13, 2024 08:37
@sqs sqs merged commit 07f9f96 into main Mar 13, 2024
16 checks passed
@sqs sqs deleted the sqs/robust-chat-history branch March 13, 2024 16:29
@sqs sqs mentioned this pull request Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants