[API] Cannot create a pending review without body (but with a file comment) #7364

Closed
opened 2025-11-02 07:24:04 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @PhenX on GitHub (May 20, 2021).

Description

Hello, while using the repo/CreatePullReview API it seems we cannot create a pending review with file comments only :
ab77a24f18/routers/api/v1/repo/pull_review.go (L498)

image

This also seems to mean that the review, event if "pending" is "published" and sends notifications and is visble in the history.

This behaviour is annoying and prevents a correct usage of file reviews via the API IMHO.

What I need to do is : be able to start pending reviews with file comments, and publish the review only when submitting the review with one of these statuses : Commented, Rejected, Approved.

Or is there something I'm doing wrong ?

Originally created by @PhenX on GitHub (May 20, 2021). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.13.6 - Git version: 2.25.1 - Operating system: Ubuntu 20.04 - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes : - https://try.gitea.io/fnetx/Documentation/pulls/126 / https://try.gitea.io/api/swagger#/repository/repoCreatePullReview (see screenshot for details) - [ ] No - Log gist: N/A ## Description Hello, while using the repo/CreatePullReview API it seems we cannot create a pending review with file comments only : https://github.com/go-gitea/gitea/blob/ab77a24f18ae45248bd6c71778fe3bfacacf864f/routers/api/v1/repo/pull_review.go#L498 ![image](https://user-images.githubusercontent.com/42170/118933570-a5c78680-b949-11eb-94b4-8229cd0da0e9.png) This also seems to mean that the review, event if "pending" is "published" and sends notifications and is visble in the history. This behaviour is annoying and prevents a correct usage of file reviews via the API IMHO. What I need to do is : be able to start pending reviews with file comments, and publish the review only when submitting the review with one of these statuses : Commented, Rejected, Approved. Or is there something I'm doing wrong ?
GiteaMirror added the issue/confirmedtype/bugmodifies/api labels 2025-11-02 07:24:04 -06:00
Author
Owner

@noerw commented on GitHub (May 20, 2021):

The unwanted body requirement comes from here:
3021d3a49b/routers/api/v1/repo/pull_review.go (L497-L498)

The fact that the pending review is published is because CreateReview() calls pull.SubmitReview(), which in turn also sends timeline comments, notifications, mentions etc; clearly the wrong function.
3021d3a49b/routers/api/v1/repo/pull_review.go (L361-L362)
3021d3a49b/services/pull/review.go (L217-L218)

There is no pull.CreateReview() function to be used instead.. To fix this, we'd need to create it, which just calls models.CreateReview() and pull.createCodeComment()

edit: this might partially be a regression of #14218?

@noerw commented on GitHub (May 20, 2021): The unwanted body requirement comes from here: https://github.com/go-gitea/gitea/blob/3021d3a49b5643a909ddf2c1388ad8d37d960b73/routers/api/v1/repo/pull_review.go#L497-L498 The fact that the pending review is published is because `CreateReview()` calls `pull.SubmitReview()`, which in turn also sends timeline comments, notifications, mentions etc; clearly the wrong function. https://github.com/go-gitea/gitea/blob/3021d3a49b5643a909ddf2c1388ad8d37d960b73/routers/api/v1/repo/pull_review.go#L361-L362 https://github.com/go-gitea/gitea/blob/3021d3a49b5643a909ddf2c1388ad8d37d960b73/services/pull/review.go#L217-L218 There is no `pull.CreateReview()` function to be used instead.. To fix this, we'd need to create it, which just calls `models.CreateReview()` and `pull.createCodeComment()` edit: this might partially be a regression of #14218?
Author
Owner

@stale[bot] commented on GitHub (Jul 21, 2021):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Jul 21, 2021): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@PhenX commented on GitHub (Jul 23, 2021):

Still relevant. Any new about this change?

@PhenX commented on GitHub (Jul 23, 2021): Still relevant. Any new about this change?
Author
Owner

@wxiaoguang commented on GitHub (Jun 27, 2025):

It should have been fixed.

Image

@wxiaoguang commented on GitHub (Jun 27, 2025): It should have been fixed. ![Image](https://github.com/user-attachments/assets/2517b7c6-06c5-4ad8-bb27-c2ff90d5b9fe)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7364