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

GetFeeds must always discard actions with dangling repo_id #19598

Merged
merged 4 commits into from
May 5, 2022

Conversation

singuliere
Copy link
Contributor

@singuliere singuliere commented May 3, 2022

models/fixtures/action.yml Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 3, 2022
@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 May 3, 2022
Copy link
Contributor

@Gusted Gusted left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, seems a bit hacky tbh. Seems like we should actually fix loadRepoOwner to not panic.

@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 May 3, 2022
Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestPrivateActivityNoVisibleForPublic fails related :/

@singuliere
Copy link
Contributor Author

singuliere commented May 4, 2022

LGTM, seems a bit hacky tbh. Seems like we should actually fix loadRepoOwner to not panic.

I agree that it feels like a hack. Now that the tests are passing I'll try to follow your suggestion. My concern is that returning an action with a nil Repo member is likely to set a trap for future code using the Action struct that goes undetected because it is a rare occurrence and not covered by the current tests.

@singuliere
Copy link
Contributor Author

singuliere commented May 4, 2022

@Gusted Added a safeguard so loadRepoOwner is no longer susceptible to panic on action.Repo == nil

@6543
Copy link
Member

6543 commented May 4, 2022

please make fmt

@techknowlogick
Copy link
Member

@singuliere please refrain from force pushes, it makes it hard to review PRs

@codecov-commenter

This comment was marked as off-topic.

@techknowlogick techknowlogick merged commit b536b65 into go-gitea:main May 5, 2022
@techknowlogick
Copy link
Member

@singuliere please send backport :)

singuliere added a commit to singuliere/gitea that referenced this pull request May 6, 2022
…19598)

Co-authored-by: Loïc Dachary <[email protected]>
(cherry picked from commit b536b65)

Conflicts:
        models/action_test.go
	  The GetFeeds function does not have a Context argument in 1.16.
	models/action.go
	  The SQL statement is essentially the same in 1.16 but
	  structured differently. The Join() was copied and the
   	  created_unix field prefixed with `action`.
	models/action_list.go
	  in 1.16 the loadRepoOwner method did not exist and
	  it was done in the RetrieveFeeds method of web/feed/profile.go.
          The safeguard to skip when act.Repo == nil was moved there.
zjjhot added a commit to zjjhot/gitea that referenced this pull request May 6, 2022
* giteaofficial/main:
  Simplify `IsVendor` (go-gitea#19626)
  Prevent NPE when checking repo units if the user is nil (go-gitea#19625)
  Skip duplicated layers. (go-gitea#19624)
  Add "Reference" section to Issue view sidebar (go-gitea#19609)
  GetFeeds must always discard actions with dangling repo_id (go-gitea#19598)
6543 pushed a commit that referenced this pull request May 8, 2022
…19629)

Co-authored-by: Loïc Dachary <[email protected]>
(cherry picked from commit b536b65)

Conflicts:
        models/action_test.go
	  The GetFeeds function does not have a Context argument in 1.16.
	models/action.go
	  The SQL statement is essentially the same in 1.16 but
	  structured differently. The Join() was copied and the
   	  created_unix field prefixed with `action`.
	models/action_list.go
	  in 1.16 the loadRepoOwner method did not exist and
	  it was done in the RetrieveFeeds method of web/feed/profile.go.
          The safeguard to skip when act.Repo == nil was moved there.
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this pull request Aug 24, 2022
…19598)

* GetFeeds must always discard actions with dangling repo_id

See https://discourse.gitea.io/t/blank-page-after-login/5051/12
for a panic in 1.16.6.

* add comment to explain the dangling ID in the fixture

* loadRepoOwner must not attempt to use a nil action.Repo

* make fmt

Co-authored-by: Loïc Dachary <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPE in routers/web/feed/profile.go:37 on 1.16.7 following failed migration
7 participants