Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: return NotFound for an unknown SearchIssues parent
Danny87e178f4b5ce
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.goindex 158581ccca..2c5ab91aab 100644--- a/backend/api/v1/issue_service.go+++ b/backend/api/v1/issue_service.go@@ -337,6 +337,19 @@ func (s *IssueService) SearchIssues(ctx context.Context, req *connect.Request[v1projectIDs = *projectIDsFilter}} else {+ // Resolve the project first so an unknown parent is a NotFound rather+ // than an INTERNAL out of CheckPermission's own project lookup. This+ // matches what the ACL interceptor does for the IAM-authorized RPCs.+ project, err := s.store.GetProject(ctx, &store.FindProjectMessage{+ Workspace: common.GetWorkspaceIDFromContext(ctx),+ ResourceID: &projectID,+ })+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get project"))+ }+ if project == nil {+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("project not found for id: %v", projectID))+ }ok, err := s.iamManager.CheckPermission(ctx, permission.IssuesGet, user, common.GetWorkspaceIDFromContext(ctx), projectID)if err != nil {return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to check permission %q", permission.IssuesGet))diff --git a/backend/tests/cross_project_update_test.go b/backend/tests/cross_project_update_test.goindex 5b1735f47e..bc534f74b6 100644--- a/backend/tests/cross_project_update_test.go+++ b/backend/tests/cross_project_update_test.go@@ -368,6 +368,16 @@ func TestSearchIssuesConcreteProjectAuthorization(t *testing.T) {"SearchIssues for project A returned an issue from another project: %s", issue.Name)}+ // An unknown parent is NotFound, not INTERNAL: CheckPermission's own+ // project lookup would otherwise surface as a 500 for a typo'd project.+ _, err = ctl.issueServiceClient.SearchIssues(ctx,+ connect.NewRequest(&v1pb.SearchIssuesRequest{+ Parent: "projects/does-not-exist",+ PageSize: 100,+ }))+ a.Error(err)+ a.Equal(connect.CodeNotFound, connect.CodeOf(err), "unknown project must be NotFound")+// The AIP-159 wildcard keeps searching across collections, restricted to// the projects the caller can read.wildcard, err := ctl.issueServiceClient.SearchIssues(ctx,@@ -398,4 +408,15 @@ func TestSearchIssuesConcreteProjectAuthorization(t *testing.T) {}}a.True(sawB, "an admin wildcard search should include project B's issues")++ // An admin holds the permission workspace-wide, so CheckPermission never+ // reaches its project lookup: without the explicit resolve, an unknown+ // project would silently return an empty page instead of NotFound.+ _, err = ctl.issueServiceClient.SearchIssues(ctx,+ connect.NewRequest(&v1pb.SearchIssuesRequest{+ Parent: "projects/does-not-exist",+ PageSize: 100,+ }))+ a.Error(err)+ a.Equal(connect.CodeNotFound, connect.CodeOf(err), "unknown project must be NotFound for an admin too")}