Disallow explicit null for optional fields#3313
Merged
jakebailey merged 7 commits intomainfrom Apr 1, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds stricter JSON unmarshaling rules for generated LSP structs so explicitly-provided null is rejected for optional non-nullable fields, and adds comprehensive tests covering (un)marshal behaviors and unions.
Changes:
- Add
typeCanBeNulland generator logic to emitnull-rejection checks for fields whose meta-model types don’t permit JSONnull - Add a broad Go test suite covering nullability rules, required-field validation, unions, discriminator handling, and round-trips
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| internal/lsp/lsproto/lsp_json_test.go | New tests validating (un)marshal behavior, especially around nullability and unions |
| internal/lsp/lsproto/_generate/generate.mts | Generator updates to detect null-capable types and reject explicit null where disallowed |
RyanCavanaugh
approved these changes
Apr 1, 2026
osiewicz
added a commit
to zed-industries/zed
that referenced
this pull request
Apr 6, 2026
This fixes a crash with new Preview versions of tsgo after microsoft/typescript-go#3313
5 tasks
osiewicz
added a commit
to zed-industries/zed
that referenced
this pull request
Apr 6, 2026
This fixes a crash with new Preview versions of tsgo after microsoft/typescript-go#3313 Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [ ] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - N/A
MasoudAlali
pushed a commit
to MasoudAlali/zed-ide
that referenced
this pull request
Apr 7, 2026
This fixes a crash with new Preview versions of tsgo after microsoft/typescript-go#3313 Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [ ] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - N/A
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.
Pointer fields were accidentally not checking for null. This has been a bug for a long time; I only noticed it when reading the diff on #3311.
While here, add some tests, for this but also previous stuff that was fixed.