Skip to content

Unable to add label to a PR from Rest API #5435

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

Closed
6 tasks
juanpablo-santos opened this issue Nov 30, 2018 · 3 comments
Closed
6 tasks

Unable to add label to a PR from Rest API #5435

juanpablo-santos opened this issue Nov 30, 2018 · 3 comments
Labels
type/enhancement An improvement of existing functionality
Milestone

Comments

@juanpablo-santos
Copy link
Contributor

  • Gitea version (or commit ref): 1.6.0
  • Git version: 2.14
  • Operating system:
  • Database (use [x]):
    • PostgreSQL
    • [ X] MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

As title says, it seems not possible to add a label to a PR through existing REST API. A /repos/{owner}/{repo}/pulls/{index} PATCH request using { "labels": [ 182 ] } as body (with that label being present for that repo) returns a 201 but the label is not added.

when using this approach xorm.log yields (selects omitted):

2018/11/30 13:21:31 [I] [SQL] UPDATE `webhook` SET `last_status` = ?, `updated_unix` = ? WHERE `id`=? []interface {}{1, 1543584091, 208}
2018/11/30 13:21:32 [I] [SQL] UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=? []interface {}{true, 5, 14879}
2018/11/30 13:22:30 [I] [SQL] UPDATE `issue` SET `repo_id` = ?, `index` = ?, `poster_id` = ?, `name` = ?, `content` = ?, `milestone_id` = ?, `priority` = ?, `is_closed` = ?, `is_pull` = ?, `num_comments` = ?, `ref` = ?, `deadline_unix` = ?, `closed_unix` = ?, `updated_unix` = ? WHERE `id`=? []interface {}{276, 215, 5, "test auto label", "testtesttesttesttesttest", 0, 0, false, true, 0, "", 0, 0, 1543584150, 14879}
2018/11/30 13:23:12 [I] [SQL] UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=? []interface {}{true, 5, 14879}

whereas, when manually adding the label to the PR, xorm.log shows (selects also omitted):

2018/11/30 13:19:03 [I] [SQL] UPDATE `webhook` SET `last_status` = ?, `updated_unix` = ? WHERE `id`=? []interface {}{1, 1543583943, 208}
2018/11/30 13:19:04 [I] [SQL] UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=? []interface {}{true, 5, 14879}
2018/11/30 13:19:26 [I] [SQL] BEGIN TRANSACTION
2018/11/30 13:19:26 [I] [SQL] INSERT INTO `issue_label` (`issue_id`,`label_id`) VALUES (?, ?) []interface {}{14879, 182}
2018/11/30 13:19:26 [I] [SQL] INSERT INTO `comment` (`type`,`poster_id`,`issue_id`,`label_id`,`old_milestone_id`,`milestone_id`,`assignee_id`,`removed_assignee`,`old_title`,`new_title`,`dependent_issue_id`,`commit_id`,`line`,`tree_path`,`content`,`patch`,`created_unix`,`updated_unix`,`commit_sha`,`review_id`,`invalidated`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) []interface {}{7, 5, 14879, 182, 0, 0, 0, false, "", "", 0, 0, 0, "", "1", "", 1543583966, 1543583966, "", 0, false}
2018/11/30 13:19:26 [I] [SQL] UPDATE `issue` SET `updated_unix` = ? WHERE `id`=? []interface {}{1543583966, 14879}
2018/11/30 13:19:26 [I] [SQL] UPDATE `label` SET `repo_id` = ?, `name` = ?, `description` = ?, `color` = ?, `num_issues` = ?, `num_closed_issues` = ? WHERE `id`=? []interface {}{276, "lgtm/need 1", "needs another review in order to be merged", "#fbca04", 1, 0, 182}
2018/11/30 13:19:26 [I] [SQL] COMMIT

Current workaround is to use instead a PUT request to /repos/{owner}/{repo}/issues/{index}/labels using the same index and set the label on the PR through the issues endpoint

@lafriks lafriks added the type/enhancement An improvement of existing functionality label Nov 30, 2018
@lafriks
Copy link
Member

lafriks commented Nov 30, 2018

I think there is already PR to fix this

@juanpablo-santos
Copy link
Contributor Author

@lafriks, perhaps #5347?

@lafriks
Copy link
Member

lafriks commented Jan 22, 2019

yes, closing as fixed

@lafriks lafriks closed this as completed Jan 22, 2019
@lafriks lafriks added this to the 1.7.0 milestone Jan 22, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants