Skip to content
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

Avoid user does not exist error when detecting schedule actions when the commit author is an external user #30357

Merged
merged 4 commits into from
Apr 11, 2024

Conversation

yp05327
Copy link
Contributor

@yp05327 yp05327 commented Apr 9, 2024

image

When repo is a mirror, and commit author is an external user, then GetUserByEmail will return error.

reproduce/test:

  • mirror Gitea to your instance
  • disable action and enable it again, this will trigger DetectAndHandleSchedules

ps: also follow #24706, it only fixed normal runs, not scheduled runs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 9, 2024
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 9, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Apr 9, 2024
@yp05327 yp05327 requested a review from wolfogre April 9, 2024 08:29
@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 10, 2024
@yp05327
Copy link
Contributor Author

yp05327 commented Apr 10, 2024

Thanks for the suggestion from @wolfogre
We should use repo owner as the user instead of commit author.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 10, 2024
@wolfogre
Copy link
Member

wolfogre commented Apr 11, 2024

Actually, I still think the repo owner is better than the gitea-action user. It's not a technical issue, but a design one.

"gitea-action" means the operation is done by Gitea Actions, like a commit has been pushed and the pusher is "gitea-action", and it shouldn't trigger another Actions run. So it's weird to say that the trigger user is "gitea-action" since it should never trigger Actions runs.

Whichever, both of them are better than the commit author.

I'm OK with this, since the actor of a scheduled run is not shown.

image

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 11, 2024
@wolfogre wolfogre added this to the 1.23.0 milestone Apr 11, 2024
@wolfogre wolfogre added backport/v1.21 This PR should be backported to Gitea 1.21 backport/v1.22 This PR should be backported to Gitea 1.22 reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Apr 11, 2024
@wolfogre wolfogre merged commit 96d31fe into go-gitea:main Apr 11, 2024
26 checks passed
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Apr 11, 2024
…the commit author is an external user (go-gitea#30357)

![image](https://github.com/go-gitea/gitea/assets/18380374/ddf6ee84-2242-49b9-b066-bd8429ba4d76)

When repo is a mirror, and commit author is an external user, then
`GetUserByEmail` will return error.

reproduce/test:
- mirror Gitea to your instance
- disable action and enable it again, this will trigger
`DetectAndHandleSchedules`

ps: also follow go-gitea#24706, it only fixed normal runs, not scheduled runs.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Apr 11, 2024
…the commit author is an external user (go-gitea#30357)

![image](https://github.com/go-gitea/gitea/assets/18380374/ddf6ee84-2242-49b9-b066-bd8429ba4d76)

When repo is a mirror, and commit author is an external user, then
`GetUserByEmail` will return error.

reproduce/test:
- mirror Gitea to your instance
- disable action and enable it again, this will trigger
`DetectAndHandleSchedules`

ps: also follow go-gitea#24706, it only fixed normal runs, not scheduled runs.
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 11, 2024
lunny pushed a commit that referenced this pull request Apr 11, 2024
…the commit author is an external user (#30357) (#30408)

Backport #30357 by @yp05327


![image](https://github.com/go-gitea/gitea/assets/18380374/ddf6ee84-2242-49b9-b066-bd8429ba4d76)

When repo is a mirror, and commit author is an external user, then
`GetUserByEmail` will return error.

reproduce/test:
- mirror Gitea to your instance
- disable action and enable it again, this will trigger
`DetectAndHandleSchedules`

ps: also follow #24706, it only fixed normal runs, not scheduled runs.

Co-authored-by: yp05327 <576951401@qq.com>
lunny pushed a commit that referenced this pull request Apr 11, 2024
…the commit author is an external user (#30357) (#30409)

Backport #30357 by @yp05327


![image](https://github.com/go-gitea/gitea/assets/18380374/ddf6ee84-2242-49b9-b066-bd8429ba4d76)

When repo is a mirror, and commit author is an external user, then
`GetUserByEmail` will return error.

reproduce/test:
- mirror Gitea to your instance
- disable action and enable it again, this will trigger
`DetectAndHandleSchedules`

ps: also follow #24706, it only fixed normal runs, not scheduled runs.

Co-authored-by: yp05327 <576951401@qq.com>
@yp05327
Copy link
Contributor Author

yp05327 commented Apr 12, 2024

@wolfogre
What about the permission when running the job? Do they have difference?

zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 12, 2024
* giteaofficial/main:
  Change the default maxPerPage for gitbucket (go-gitea#30392)
  Fix the spacing issue in the Project view (go-gitea#30415)
  Add commit status summary table to reduce query from commit status table (go-gitea#30223)
  Split `issue edit` code from `repo-legacy.js` into its own file (go-gitea#30419)
  Check the token's owner and repository when registering a runner (go-gitea#30406)
  Avoid user does not exist error when detecting schedule actions when the commit author is an external user (go-gitea#30357)
  Update actions variables documents (go-gitea#30394)
  Fix author name alignment in commits table (go-gitea#30396)
@wolfogre
Copy link
Member

@wolfogre What about the permission when running the job? Do they have difference?

No, the permission when running the job is not decided by the trigger user.

@lunny lunny added the backport/done All backports for this PR have been created label Apr 12, 2024
silverwind pushed a commit that referenced this pull request Apr 20, 2024
Follow #30357

When user push to default branch, the schedule trigger user will be the
user.
When disable then enable action units in settings, the schedule trigger
user will be action user.
When repo is a mirror, the schedule trigger user will be action user. (
before it will return error, fixed by #30357)

As scheduled job is a cron, the trigger user should be action user from
Gitea, not a real user.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
GiteaBot added a commit to GiteaBot/gitea that referenced this pull request Apr 20, 2024
Follow go-gitea#30357

When user push to default branch, the schedule trigger user will be the
user.
When disable then enable action units in settings, the schedule trigger
user will be action user.
When repo is a mirror, the schedule trigger user will be action user. (
before it will return error, fixed by go-gitea#30357)

As scheduled job is a cron, the trigger user should be action user from
Gitea, not a real user.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
GiteaBot added a commit to GiteaBot/gitea that referenced this pull request Apr 20, 2024
Follow go-gitea#30357

When user push to default branch, the schedule trigger user will be the
user.
When disable then enable action units in settings, the schedule trigger
user will be action user.
When repo is a mirror, the schedule trigger user will be action user. (
before it will return error, fixed by go-gitea#30357)

As scheduled job is a cron, the trigger user should be action user from
Gitea, not a real user.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
lunny pushed a commit that referenced this pull request Apr 20, 2024
Backport #30581 by @yp05327

Follow #30357

When user push to default branch, the schedule trigger user will be the
user.
When disable then enable action units in settings, the schedule trigger
user will be action user.
When repo is a mirror, the schedule trigger user will be action user. (
before it will return error, fixed by #30357)

As scheduled job is a cron, the trigger user should be action user from
Gitea, not a real user.

Co-authored-by: yp05327 <576951401@qq.com>
lunny pushed a commit that referenced this pull request Apr 20, 2024
Backport #30581 by @yp05327

Follow #30357

When user push to default branch, the schedule trigger user will be the
user.
When disable then enable action units in settings, the schedule trigger
user will be action user.
When repo is a mirror, the schedule trigger user will be action user. (
before it will return error, fixed by #30357)

As scheduled job is a cron, the trigger user should be action user from
Gitea, not a real user.

Co-authored-by: yp05327 <576951401@qq.com>
DennisRasey pushed a commit to DennisRasey/forgejo that referenced this pull request Apr 22, 2024
Follow go-gitea/gitea#30357

When user push to default branch, the schedule trigger user will be the
user.
When disable then enable action units in settings, the schedule trigger
user will be action user.
When repo is a mirror, the schedule trigger user will be action user. (
before it will return error, fixed by #30357)

As scheduled job is a cron, the trigger user should be action user from
Gitea, not a real user.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit cb6814adad4dc81a683b50826a211ce7bce731d7)

Conflicts:
	- services/actions/notifier_helper.go
	  Conflict resolved by keeping Forgejo's version of the line.
(cherry picked from commit 829c3c6)
DennisRasey pushed a commit to DennisRasey/forgejo that referenced this pull request Apr 22, 2024
Follow go-gitea/gitea#30357

When user push to default branch, the schedule trigger user will be the
user.
When disable then enable action units in settings, the schedule trigger
user will be action user.
When repo is a mirror, the schedule trigger user will be action user. (
before it will return error, fixed by #30357)

As scheduled job is a cron, the trigger user should be action user from
Gitea, not a real user.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit cb6814adad4dc81a683b50826a211ce7bce731d7)

Conflicts:
	- services/actions/notifier_helper.go
	  Conflict resolved by keeping Forgejo's version of the line.
uli-heller pushed a commit to uli-heller/forgejo that referenced this pull request Apr 24, 2024
Follow go-gitea/gitea#30357

When user push to default branch, the schedule trigger user will be the
user.
When disable then enable action units in settings, the schedule trigger
user will be action user.
When repo is a mirror, the schedule trigger user will be action user. (
before it will return error, fixed by #30357)

As scheduled job is a cron, the trigger user should be action user from
Gitea, not a real user.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit cb6814adad4dc81a683b50826a211ce7bce731d7)

Conflicts:
	- services/actions/notifier_helper.go
	  Conflict resolved by keeping Forgejo's version of the line.
(cherry picked from commit 829c3c683837b8c7e278565d64369a5216c271f1)
@wxiaoguang wxiaoguang added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.21 This PR should be backported to Gitea 1.21 backport/v1.22 This PR should be backported to Gitea 1.22 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code size/S Denotes a PR that changes 10-29 lines, ignoring generated files. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants