Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

fix siteadmin check in users connection endpoint#55322

Merged
Strum355 merged 2 commits intomainfrom
nsc/user-resolver-actor-nil
Jul 26, 2023
Merged

fix siteadmin check in users connection endpoint#55322
Strum355 merged 2 commits intomainfrom
nsc/user-resolver-actor-nil

Conversation

@Strum355
Copy link
Contributor

https://github.com/sourcegraph/sourcegraph/pull/50228 introduced a new actor field on UserResolver to reduce amount of user lookups required.
This wasnt being set in all places (or it was assumed that all instantiation of UserResolver was through NewUserResolver), resulting in actor being unset for this codepath, and hence nil panic when any of the fields that would reference the new field.

Not sure who to request PR review from, so feel free to stamp

Test plan

Added unit test coverage and manual testing in API console

@Strum355 Strum355 requested review from a team, mrnugget and sashaostrikov July 26, 2023 15:38
@Strum355 Strum355 self-assigned this Jul 26, 2023
@cla-bot cla-bot bot added the cla-signed label Jul 26, 2023
Copy link
Contributor

@sashaostrikov sashaostrikov left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! 🙏

@Strum355 Strum355 enabled auto-merge (squash) July 26, 2023 15:45
log.Object("repo",
log.String("user", user.Username))),
})
l = append(l, NewUserResolver(ctx, r.db, user))
Copy link
Member

Choose a reason for hiding this comment

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

I think if using the user resolver directly is not valid, we should not export it either.

This PR is a good fix and can land quickly, but I would love to see us follow up with unexporting the type :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its in the same package either way so it wouldnt have helped for this case, but agreed

Copy link
Member

Choose a reason for hiding this comment

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

ty for tests!

@Strum355 Strum355 merged commit c3bfec8 into main Jul 26, 2023
@Strum355 Strum355 deleted the nsc/user-resolver-actor-nil branch July 26, 2023 15:53
github-actions bot pushed a commit that referenced this pull request Jul 26, 2023
https://github.com/sourcegraph/sourcegraph/pull/50228 introduced a new
`actor` field on `UserResolver` to reduce amount of user lookups
required.
This wasnt being set in all places (or it was assumed that all
instantiation of `UserResolver` was through `NewUserResolver`),
resulting in actor being unset for this codepath, and hence nil panic
when any of the fields that would reference the new field.

Not sure who to request PR review from, so feel free to stamp

## Test plan

Added unit test coverage and manual testing in API console

(cherry picked from commit c3bfec8)
coury-clark pushed a commit that referenced this pull request Jul 26, 2023
https://github.com/sourcegraph/sourcegraph/pull/50228 introduced a new
`actor` field on `UserResolver` to reduce amount of user lookups
required.
This wasnt being set in all places (or it was assumed that all
instantiation of `UserResolver` was through `NewUserResolver`),
resulting in actor being unset for this codepath, and hence nil panic
when any of the fields that would reference the new field.

Not sure who to request PR review from, so feel free to stamp

## Test plan

Added unit test coverage and manual testing in API console
 <br> Backport c3bfec8 from #55322

Co-authored-by: Noah S-C <noah@sourcegraph.com>
MaedahBatool pushed a commit that referenced this pull request Jul 28, 2023
https://github.com/sourcegraph/sourcegraph/pull/50228 introduced a new
`actor` field on `UserResolver` to reduce amount of user lookups
required.
This wasnt being set in all places (or it was assumed that all
instantiation of `UserResolver` was through `NewUserResolver`),
resulting in actor being unset for this codepath, and hence nil panic
when any of the fields that would reference the new field.

Not sure who to request PR review from, so feel free to stamp

## Test plan

Added unit test coverage and manual testing in API console
davejrt pushed a commit that referenced this pull request Aug 9, 2023
https://github.com/sourcegraph/sourcegraph/pull/50228 introduced a new
`actor` field on `UserResolver` to reduce amount of user lookups
required.
This wasnt being set in all places (or it was assumed that all
instantiation of `UserResolver` was through `NewUserResolver`),
resulting in actor being unset for this codepath, and hence nil panic
when any of the fields that would reference the new field.

Not sure who to request PR review from, so feel free to stamp

## Test plan

Added unit test coverage and manual testing in API console
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants