Skip to content

Updating issues via API does not work if "state" field is present but unchanged #31871

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
splitt3r opened this issue Aug 19, 2024 · 5 comments
Closed
Labels
Milestone

Comments

@splitt3r
Copy link
Contributor

splitt3r commented Aug 19, 2024

Description

If i try to update an issue via:

curl --location --request PATCH 'http://localhost:3000/api/v1/repos/root/test/issues/1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ***' \
--data '{
  "assignees": [],
  "body": "Test 123",
  "title": "Dependency Dashboard",
  "state": "open"
}'

The issue is updated just fine but Gitea returns status code 500.

The problem here is the state field. Without the state field everything works just fine.

I think the problem was introduced with a50026e#diff-f33622667aa80c1735ccaef8e7331422504e8c449f691c6847ec4f6737a278cd. @yp05327 maybe you can have a look at it.

The problem occured because Renovate Bot useses the state field in its model (see https://github.com/renovatebot/renovate/blob/main/lib/modules/platform/gitea/types.ts#L171-L176) for issue creation / update via the Gitea API.

Gitea Version

1.22.1

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

The logs:

2024/08/19 07:11:13 ...api/v1/repo/issue.go:894:EditIssue() [E] ChangeStatus: Issue [1] 0 was already closed
2024/08/19 07:11:13 ...eb/routing/logger.go:102:func1() [I] router: completed PATCH /api/v1/repos/root/test/issues/1 for 172.17.0.1:36648, 500 Internal Server Error in 33.5ms @ repo/issue.go:742(repo.EditIssue)

The API returns:

{
    "message": "Issue [1] 0 was already closed",
    "url": "http://localhost:3000/api/swagger"
}

Git Version

No response

Operating System

No response

How are you running Gitea?

Docker

Database

SQLite

@yp05327
Copy link
Contributor

yp05327 commented Aug 19, 2024

Thanks for your report. I will check it later.

@splitt3r splitt3r changed the title Updating issues via API does not work if "state" field is present Updating issues via API does not work if "state" field is present but unchanged Aug 19, 2024
@yp05327
Copy link
Contributor

yp05327 commented Aug 19, 2024

I got this error. But the issue is opening not closed.
image

I think it is not related to the changes you mentioned. It looks that this is an old bug.
image

Nothing should be performed if current status is same as target status

The logic here is a bit strange, nothing should be performed but it returns issue/PR closed error. 😕
I need to figure out where these codes come from, I have no time today, I will do it tomorrow.

@yp05327
Copy link
Contributor

yp05327 commented Aug 19, 2024

Emmm, this logic can be traced far before (about 5 years ago). No need to figure out it any more, just need to find a solution to fix it.

@yp05327
Copy link
Contributor

yp05327 commented Aug 20, 2024

I see. It was part of my fault. But I still think the logic in changeIssueStatus is strange.

@splitt3r
Copy link
Contributor Author

splitt3r commented Sep 1, 2024

@yp05327 thanks for the quick fix. Great work 👍🏻

@splitt3r splitt3r closed this as completed Sep 1, 2024
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants