Repository navigation
Conversation
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.
Problem
DiscussionNotePositionTextSchematypesnew_lineandold_lineas strings, but the discussions API returns them as numbers, and asnullfor the side of the diff a line doesn't exist on. A diff note on an added line comes back as:{ "position": { "base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef", "start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306", "head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031", "old_path": "package.json", "new_path": "package.json", "position_type": "text", "old_line": null, "new_line": 19 } }Observed on every diff note sampled on a self-managed GitLab instance; the docs example shows the same numbers (
"old_line": 27, "new_line": 27). The siblingDiscussionNotePositionTextLineSchema(used byline_range) already types these fields asnumber.Consumers reading a note's position currently have to cast
new_linetonumber.Change
new_line?: string; old_line?: string→new_line?: number | null; old_line?: number | nullonDiscussionNotePositionTextSchema.DiscussionNotePositionOptionswas derived from this schema withCamelize<>, so a plain edit would also have turned the request optionposition.newLineinto a number and broken every caller passing a string. The text variant's shared fields move to a localDiscussionNotePositionTextBaseSchema, and the options keep theirstringline numbers on top of it. The request type is unchanged; I checked that the old and newDiscussionNotePositionOptionsare identical types.Types only, no runtime change. Code that reads
position.new_lineas a string (for example.padStart()or a comparison against a string) is now flagged; it was receiving numbers at runtime already.MergeRequestDraftNotePositionSchemabuilds on the same union, so draft note positions get the same correction.The docs example also shows
"old_line": nullinsideline_range.start, soDiscussionNotePositionTextLineSchemais probably nullable too. I left it alone here because the options type still derives from it.