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

[bug] Display user permissions even if the GQL resolver has errors#57375

Merged
pjlast merged 7 commits into
mainfrom
pjlast/fix-user-perms-screen-if-admin-cant-see-repo
Oct 5, 2023
Merged

[bug] Display user permissions even if the GQL resolver has errors#57375
pjlast merged 7 commits into
mainfrom
pjlast/fix-user-perms-screen-if-admin-cant-see-repo

Conversation

@pjlast

@pjlast pjlast commented Oct 5, 2023

Copy link
Copy Markdown
Contributor

Fixes an issue where admins can't view a user's permissions if they don't have access to all of the repos a user has access to.

Previously the page would just load forever, now admins are told they can't see the repo:

image

Test plan

Manual tests

@cla-bot cla-bot Bot added the cla-signed label Oct 5, 2023
@pjlast pjlast requested a review from a team October 5, 2023 11:40
@sourcegraph-bot

sourcegraph-bot commented Oct 5, 2023

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

Comment thread internal/database/perms_store.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we write a test for this?

Comment thread CHANGELOG.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

very nice changelog entry!

Comment thread client/web/src/components/FilteredConnection/hooks/usePageSwitcherPagination.ts Outdated
Comment thread internal/database/perms_store.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we get a query plan for this on scaletesting or so, to avoid regressions? Just to be safe.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, I wish a test had to be adjusted after this change 😢 Can we at least add a new test that verifies this new behavior? :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In an ideal world, we would check for the error at this nodes path and make sure it is actually a no access error - otherwise errors from loading the repo or so could bubble up here as a "no access error"
that said, I don't think we are generally following a ton of great practices around apollo so don't feel obligated to be the first one to care 😬

Comment thread client/web/src/enterprise/user/settings/auth/UserSettingsPermissionsPage.tsx Outdated
Comment thread client/web/src/enterprise/user/settings/auth/UserSettingsPermissionsPage.tsx Outdated
@pjlast pjlast force-pushed the pjlast/fix-user-perms-screen-if-admin-cant-see-repo branch from 5ad8e7e to ff154de Compare October 5, 2023 13:40
@sourcegraph-bot

sourcegraph-bot commented Oct 5, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 52be312...38c3fef.

Notify File(s)
@unknwon cmd/frontend/internal/authz/resolvers/permissions_info.go

Comment on lines +102 to +107
repoID, err := graphqlbackend.UnmarshalRepositoryID(graphql.ID(cursor))
if err != nil {
return nil, err
}

cursorSQL := strconv.Itoa(int(repoID))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't know why this was based on repo name instead of ID, as that is what you'd have access to for the cursor

const debouncedQuery = useDebounce(query, 300)

const { connection, data, loading, error, refetch, variables, ...paginationProps } = usePageSwitcherPagination<
const { connection, data, loading, refetch, variables, ...paginationProps } = usePageSwitcherPagination<

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

was error unused? I don't see where a reference to it was removed in this diff 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah it was unused

type PermissionsInfoRepositoryResolver interface {
ID() graphql.ID
Repository() *RepositoryResolver
Repository(ctx context.Context) (*RepositoryResolver, error)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fact that it was already nullable kind of convinced me that this is the right change :D

@pjlast pjlast merged commit 18c70e0 into main Oct 5, 2023
@pjlast pjlast deleted the pjlast/fix-user-perms-screen-if-admin-cant-see-repo branch October 5, 2023 15:54
sourcegraph-release-bot pushed a commit that referenced this pull request Oct 5, 2023
keegancsmith added a commit that referenced this pull request Oct 16, 2023
…r has errors (#57385)

[bug] Display user permissions even if the admin does not have access to all repos (#57375)

(cherry picked from commit 18c70e0)

Co-authored-by: Petri-Johan Last <petri.last@sourcegraph.com>
Co-authored-by: Keegan Carruthers-Smith <keegan.csmith@gmail.com>
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