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

Fix broken diff search if sub-repo perms are enabled#53210

Merged
pjlast merged 5 commits into
mainfrom
pjlast/fix-sub-repo-diff-search
Jun 9, 2023
Merged

Fix broken diff search if sub-repo perms are enabled#53210
pjlast merged 5 commits into
mainfrom
pjlast/fix-sub-repo-diff-search

Conversation

@pjlast

@pjlast pjlast commented Jun 9, 2023

Copy link
Copy Markdown
Contributor

When sub-repo permissions are enabled, the sub-repo permissions filter would be applied to repositories where sub-repo permissions are relevant. This lead to type:diff search being broken when sub-repo permissions are enabled, since it would try to filter repositories for which sub-repo permissions do not apply.

This PR changes the check to confirm that sub-repo permissions are enabled for the repository being filtered before doing the sub-repo filter, and if the repository does not have sub-repo permissions enabled, the repository is skipped.

Test plan

Verified with manual checks. Added unit test.

@sourcegraph-bot

sourcegraph-bot commented Jun 9, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff cf3321c...5ab84e8.

Notify File(s)
@camdencheek internal/search/job/jobutil/sub_repo_perms_job.go
internal/search/job/jobutil/sub_repo_perms_job_test.go
@jtibshirani internal/search/job/jobutil/sub_repo_perms_job.go
internal/search/job/jobutil/sub_repo_perms_job_test.go
@keegancsmith cmd/frontend/graphqlbackend/search_results_test.go
internal/search/job/jobutil/sub_repo_perms_job.go
internal/search/job/jobutil/sub_repo_perms_job_test.go

@pjlast pjlast requested review from a team and ggilmore June 9, 2023 08:31

@sashaostrikov sashaostrikov left a comment

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.

Nice fix!

@pjlast pjlast enabled auto-merge (squash) June 9, 2023 08:59

@kopancek kopancek left a comment

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.

Do we want to backport this @pjlast ?

@pjlast pjlast merged commit 24c34a1 into main Jun 9, 2023
@pjlast pjlast deleted the pjlast/fix-sub-repo-diff-search branch June 9, 2023 09:47
github-actions Bot pushed a commit that referenced this pull request Jun 9, 2023

@keegancsmith keegancsmith left a comment

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.

It is surprising to me that authz.CanReadAnyPath doesn't return true if subrepoperms are disabled. That feels like the proper fix?

Comment thread CHANGELOG.md
- SAML assertions to get user display name are now compared case insensitively and we do not always return an error. [#52992](https://github.com/sourcegraph/sourcegraph/pull/52992)
- The braindot menu on the blob view no longer fetches data eagerly to prevent performance issues for larger monorepo users. [#53039](https://github.com/sourcegraph/sourcegraph/pull/53039)
- Fixed an issue where commenting out redacted site-config secrets would re-add the secrets. [#53152](https://github.com/sourcegraph/sourcegraph/pull/53152)
- Fixed an issue where `type:diff` search would not work when sub-repo permissions are enabeld. [#53210](https://github.com/sourcegraph/sourcegraph/pull/53210)

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.

typo: enabled

for _, m := range matches {
enabled, err := authz.SubRepoEnabledForRepo(ctx, checker, m.Key().Repo)
if err != nil {
logger.Warn(fmt.Sprintf("Could not determine if sub-repo permissions are enabled for repo %s. Skipping.", m.Key().Repo))

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.

this is not how you should use logger. Pass a message then use log.String("repo", m.Key().Repo) as a parameter

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.

Woops, let me make a follow-up PR. Thanks!

@keegancsmith

Copy link
Copy Markdown
Member

unknwon pushed a commit that referenced this pull request Jun 14, 2023
…53218)

When sub-repo permissions are enabled, the sub-repo permissions filter
would be applied to repositories where sub-repo permissions are
relevant. This lead to `type:diff` search being broken when sub-repo
permissions are enabled, since it would try to filter repositories for
which sub-repo permissions do not apply.

This PR changes the check to confirm that sub-repo permissions are
enabled for the repository being filtered before doing the sub-repo
filter, and if the repository does not have sub-repo permissions
enabled, the repository is skipped.

## Test plan

Verified with manual checks. Added unit test.

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
 <br> Backport 24c34a1 from #53210

Co-authored-by: Petri-Johan Last <petri.last@sourcegraph.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.

6 participants