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.
feat: add CreatePullRequestInlineComment for line-level PR comments #1
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
Uh oh!
There was an error while loading. Please reload this page.
feat: add CreatePullRequestInlineComment for line-level PR comments #1
Changes from all commits
0563e40File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[MAJOR] 潜在问题:
Line字段类型为int,零值为0,且 JSON tag 中没有omitempty。这意味着如果调用者未设置Line,请求体中会发送"line": 0,这在 GitHub API 中是无效的(行[security] 潜在问题:
Line字段类型为int,零值为0,且 JSON tag 中没有omitempty。这意味着如果调用者未设置Line,请求体中会发送"line": 0,这在 GitHub API 中是无效的(行号从 1 开始),可能导致 API 返回不明确的错误。建议:可以考虑将
Line改为指针类型*int,这样可以区分"未设置"和"设置为 0"的情况,或者在CreatePullRequestInlineComment方法中添加对必填字段(Body、Path、Line、Side)的基本校验,提前返回有意义的错误信息。[frontend] 潜在问题:
Line字段类型为int,零值为0。当调用者不设置Line(例如使用position方式定位评论)时,JSON 序列化会发送"line": 0,这可能导致 GitHub API 返回错误(因为行号 0 是无效的)。建议添加
omitemptytag,或者考虑使用*int指针类型来区分"未设置"和"设置为 0"的情况。同理,Side字段也建议添加omitempty,以保持与项目中其他 Options 结构体的一致性(如CreatePullRequestOptions中可选字段使用omitempty)。[backend] 潜在问题:
Line和Side字段缺少omitempty标签。当调用方未设置这些字段时,JSON 序列化会将Line: 0和Side: ""发送到 API,可能导致 API 返回错误(GitHub API 中 line 从 1 开始,side 必须是 "LEFT" 或 "RIGHT")。如果这些字段是创建 inline comment 的必填项,建议在方法中添加参数校验(例如检查
Line > 0、Side为合法值、Body和Path非空),以便在客户端提前返回有意义的错误信息,而不是依赖 API 端的报错。如果这些字段是可选的,则应添加
omitempty标签。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[MAJOR] 潜在问题:
Line字段类型为int,零值为0,且 JSON tag 中没有omitempty。这意味着如果调用者未设置Line,请求体中会发送"line": 0,这在 GitHub API 中是无效的(行[security] 潜在问题:
Line字段类型为int,零值为0,且 JSON tag 中没有omitempty。这意味着如果调用者未设置Line,请求体中会发送"line": 0,这在 GitHub API 中是无效的(行号从 1 开始),可能导致 API 返回不明确的错误。建议:可以考虑将
Line改为指针类型*int,这样可以区分"未设置"和"设置为 0"的情况,或者在CreatePullRequestInlineComment方法中添加对必填字段(Body、Path、Line、Side)的基本校验,提前返回有意义的错误信息。[frontend] 潜在问题:
Line字段类型为int,零值为0。当调用者不设置Line(例如使用position方式定位评论)时,JSON 序列化会发送"line": 0,这可能导致 GitHub API 返回错误(因为行号 0 是无效的)。建议添加
omitemptytag,或者考虑使用*int指针类型来区分"未设置"和"设置为 0"的情况。同理,Side字段也建议添加omitempty,以保持与项目中其他 Options 结构体的一致性(如CreatePullRequestOptions中可选字段使用omitempty)。[backend] 潜在问题:
Line和Side字段缺少omitempty标签。当调用方未设置这些字段时,JSON 序列化会将Line: 0和Side: ""发送到 API,可能导致 API 返回错误(GitHub API 中 line 从 1 开始,side 必须是 "LEFT" 或 "RIGHT")。如果这些字段是创建 inline comment 的必填项,建议在方法中添加参数校验(例如检查
Line > 0、Side为合法值、Body和Path非空),以便在客户端提前返回有意义的错误信息,而不是依赖 API 端的报错。如果这些字段是可选的,则应添加
omitempty标签。