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: issue search params (#17523)
ecmadao0491ace42425
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.goindex 182069bb63..b06990bf82 100644--- a/backend/api/v1/issue_service.go+++ b/backend/api/v1/issue_service.go@@ -131,13 +131,17 @@ func (s *IssueService) getIssueFind(ctx context.Context, filter string, query st}issueFind.InstanceID = &database.InstanceIDissueFind.DatabaseName = &database.DatabaseName- case "has_pipeline":- hasPipeline, ok := value.(bool)+ case "environment":+ environment, ok := value.(string)if !ok {- return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf(`"has_pipeline" should be bool`))+ return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("failed to parse value %v to string", value))}- if !hasPipeline {- issueFind.NoPipeline = true+ if environment != "" {+ environmentID, err := common.GetEnvironmentID(environment)+ if err != nil {+ return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid environment filter %q", value))+ }+ issueFind.EnvironmentID = &environmentID}case "status":issueStatus, err := convertToAPIIssueStatus(v1pb.IssueStatus(v1pb.IssueStatus_value[value.(string)]))diff --git a/backend/generated-go/v1/issue_service.pb.go b/backend/generated-go/v1/issue_service.pb.goindex b949fa0832..5ead6ddcbb 100644--- a/backend/generated-go/v1/issue_service.pb.go+++ b/backend/generated-go/v1/issue_service.pb.go@@ -585,14 +585,15 @@ type ListIssuesRequest struct {// - task_type: support "==" operator, the value can be "DDL", "DML" or "DATA_EXPORT"// - instance: the instance full name in the "instances/{id}" format, support "==" operator.// - database: the database full name in the "instances/{id}/databases/{name}" format, support "==" operator.+ // - environment: the database full name in the "environments/{name}" format, support "==" operator.// - labels: the issue labels, support "==" and "in" operator.- // - has_pipeline: the issue has pipeline or not, support "==" operator, the value should be "true" or "false".//// For example:// creator == "users/[email protected]" && status in ["OPEN", "DONE"]// status == "CANCELED" && type == "DATABASE_CHANGE"// instance == "instances/sample" && labels in ["label1", "label2"]- // has_pipeline == true && create_time >= "2025-01-02T15:04:05Z07:00"+ // create_time >= "2025-01-02T15:04:05Z07:00"+ // environment == "environments/test"Filter string `protobuf:"bytes,4,opt,name=filter,proto3" json:"filter,omitempty"`// Query is the query statement.Query string `protobuf:"bytes,5,opt,name=query,proto3" json:"query,omitempty"`diff --git a/backend/store/issue.go b/backend/store/issue.goindex d1b58cec1d..d701c9a3d1 100644--- a/backend/store/issue.go+++ b/backend/store/issue.go@@ -86,6 +86,8 @@ type FindIssueMessage struct {// Any of the task in the issue changes the database with InstanceID and DatabaseName.InstanceID *stringDatabaseName *string+ // Should match the task environment.+ EnvironmentID *string// If specified, then it will only fetch "Limit" most recently updated issuesLimit *intOffset *int@@ -326,6 +328,10 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Isswhere = append(where, fmt.Sprintf("EXISTS (SELECT 1 FROM task WHERE task.pipeline_id = issue.pipeline_id AND task.type = ANY($%d))", len(args)+1))args = append(args, taskTypeStrings)}+ if v := find.EnvironmentID; v != nil {+ where = append(where, fmt.Sprintf("EXISTS (SELECT 1 FROM task WHERE task.pipeline_id = issue.pipeline_id AND task.environment = $%d)", len(args)+1))+ args = append(args, *v)+ }limitOffsetClause := ""if v := find.Limit; v != nil {limitOffsetClause = fmt.Sprintf(" LIMIT %d", *v)diff --git a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vueindex a58b816cfa..a2f3018f66 100644--- a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue+++ b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue@@ -43,7 +43,7 @@ import { ref, computed } from "vue";import AdvancedSearch from "@/components/AdvancedSearch";import TimeRange from "@/components/AdvancedSearch/TimeRange.vue";import type { SearchParams, SearchScopeId } from "@/utils";-import { UIIssueFilterScopeIdList, useSearchScopeIdList } from "@/utils";+import { UIIssueFilterScopeIdList } from "@/utils";import Status from "./Status.vue";import { useIssueSearchScopeOptions } from "./useIssueSearchScopeOptions";@@ -67,14 +67,23 @@ defineEmits<{(event: "update:params", params: SearchParams): void;}>();-const SearchScopeIdList = useSearchScopeIdList();const showTimeRange = ref(false);-const allowedScopes = computed(() => {+const allowedScopes = computed((): SearchScopeId[] => {if (props.overrideScopeIdList && props.overrideScopeIdList.length > 0) {return props.overrideScopeIdList;}- return [...UIIssueFilterScopeIdList, ...SearchScopeIdList.value];+ return [+ ...UIIssueFilterScopeIdList,+ "creator",+ "instance",+ "database",+ "status",+ "taskType",+ "issue-label",+ "project",+ "environment",+ ];});const scopeOptions = useIssueSearchScopeOptions(diff --git a/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vueindex 37f367a412..ea720aab24 100644--- a/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue+++ b/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue@@ -23,7 +23,7 @@<!-- Project Labels Section --><div>- <div class="font-medium mb-2">+ <div class="font-medium">{{ $t("common.labels") }}</div><div class="text-sm text-gray-500 mb-3">diff --git a/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vueindex 45a217720e..e6afd4886c 100644--- a/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue+++ b/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue@@ -210,7 +210,7 @@{{ $t("project.settings.issue-related.max-retries.self") }}</span></p>- <p class="mt-1 mb-3 text-sm text-gray-400">+ <p class="mb-3 text-sm text-gray-400">{{ $t("project.settings.issue-related.max-retries.description") }}</p><div class="mt-3 w-full flex flex-row justify-start items-center gap-4">@@ -232,7 +232,7 @@{{ $t("project.settings.issue-related.ci-sampling-size.self") }}</span></p>- <p class="mt-1 mb-3 text-sm text-gray-400">+ <p class="mb-3 text-sm text-gray-400">{{$t("project.settings.issue-related.ci-sampling-size.description")}}@@ -259,7 +259,7 @@}}</span></p>- <p class="mt-1 mb-3 text-sm text-gray-400">+ <p class="mb-3 text-sm text-gray-400">{{$t("project.settings.issue-related.parallel_tasks_per_rollout.description"diff --git a/frontend/src/store/modules/v1/issue.ts b/frontend/src/store/modules/v1/issue.tsindex aeaf86cc66..9bb00ebec1 100644--- a/frontend/src/store/modules/v1/issue.ts+++ b/frontend/src/store/modules/v1/issue.ts@@ -71,12 +71,12 @@ export const buildIssueFilter = (find: IssueFilter): string => {if (find.database) {filter.push(`database == "${find.database}"`);}+ if (find.environment) {+ filter.push(`environment == "${find.environment}"`);+ }if (find.labels && find.labels.length > 0) {filter.push(`labels in [${find.labels.map((l) => `"${l}"`).join(",")}]`);}- if (find.hasPipeline !== undefined) {- filter.push(`has_pipeline == "${find.hasPipeline}"`);- }return filter.join(" && ");};diff --git a/frontend/src/types/proto-es/v1/issue_service_pb.d.ts b/frontend/src/types/proto-es/v1/issue_service_pb.d.tsindex 45370f6e04..c97a2870db 100644--- a/frontend/src/types/proto-es/v1/issue_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/issue_service_pb.d.ts@@ -107,14 +107,15 @@ export declare type ListIssuesRequest = Message<"bytebase.v1.ListIssuesRequest">* - task_type: support "==" operator, the value can be "DDL", "DML" or "DATA_EXPORT"* - instance: the instance full name in the "instances/{id}" format, support "==" operator.* - database: the database full name in the "instances/{id}/databases/{name}" format, support "==" operator.+ * - environment: the database full name in the "environments/{name}" format, support "==" operator.* - labels: the issue labels, support "==" and "in" operator.- * - has_pipeline: the issue has pipeline or not, support "==" operator, the value should be "true" or "false".** For example:* creator == "users/[email protected]" && status in ["OPEN", "DONE"]* status == "CANCELED" && type == "DATABASE_CHANGE"* instance == "instances/sample" && labels in ["label1", "label2"]- * has_pipeline == true && create_time >= "2025-01-02T15:04:05Z07:00"+ * create_time >= "2025-01-02T15:04:05Z07:00"+ * environment == "environments/test"** @generated from field: string filter = 4;*/diff --git a/frontend/src/types/v1/issue/issue.ts b/frontend/src/types/v1/issue/issue.tsindex ebf5ec0076..750c2b4126 100644--- a/frontend/src/types/v1/issue/issue.ts+++ b/frontend/src/types/v1/issue/issue.ts@@ -63,6 +63,7 @@ export interface IssueFilter {project: string;instance?: string;database?: string;+ environment?: string;query: string;creator?: string;statusList?: IssueStatus[];@@ -74,5 +75,4 @@ export interface IssueFilter {taskType?: string;// filter by labels, for example: labels = "feature & bug"labels?: string[];- hasPipeline?: boolean;}diff --git a/frontend/src/utils/v1/advanced-search/common.ts b/frontend/src/utils/v1/advanced-search/common.tsindex d860e87d15..5a5aadf8da 100644--- a/frontend/src/utils/v1/advanced-search/common.ts+++ b/frontend/src/utils/v1/advanced-search/common.ts@@ -1,5 +1,4 @@import { cloneDeep, pullAt } from "lodash-es";-import { computed } from "vue";export type SemanticIssueStatus = "OPEN" | "CLOSED";@@ -43,11 +42,6 @@ export const AllSearchScopeIdList = [// rollout related search scopes."stage",] as const;-export const useSearchScopeIdList = () => {- return computed(() => {- return AllSearchScopeIdList;- });-};export type SearchScopeId =| (typeof AllSearchScopeIdList)[number]diff --git a/frontend/src/utils/v1/advanced-search/issue/ui-filter.ts b/frontend/src/utils/v1/advanced-search/issue/ui-filter.tsindex 706e60f2f0..b363b59248 100644--- a/frontend/src/utils/v1/advanced-search/issue/ui-filter.ts+++ b/frontend/src/utils/v1/advanced-search/issue/ui-filter.ts@@ -3,6 +3,7 @@ import {releaserCandidatesForIssue,useWrappedReviewStepsV1,} from "@/components/IssueV1/logic";+import { userNamePrefix } from "@/store";import type { ComposedIssue } from "@/types";import { Issue_Approver_Status } from "@/types/proto-es/v1/issue_service_pb";import { isUserIncludedInList } from "@/utils";@@ -38,7 +39,7 @@ export const filterIssueByApprover = (// We support "approver:{email}" by now// Planning to support "approver:[{email_1}, {email_2}, ...]" and// "approver:roles/{role}" in the future- if (approver.startsWith("users/")) {+ if (approver.startsWith(userNamePrefix)) {return currentStep.candidates.includes(approver);}@@ -58,7 +59,7 @@ export const filterIssueByReleaser = (// We support "release:{email}" by now// Planning to support "release:[{email_1}, {email_2}, ...]" and// "release:roles/{role}" in the future- if (releaser.startsWith("users/")) {+ if (releaser.startsWith(userNamePrefix)) {const candidates = releaserCandidatesForIssue(issue);return isUserIncludedInList(releaser, candidates);}@@ -116,8 +117,8 @@ export const getIssueApprovalStatusFromSearchParams = (export const buildUIIssueFilterBySearchParams = (params: SearchParams) => {const uiIssueFilter: UIIssueFilter = {approval: getIssueApprovalStatusFromSearchParams(params),- approver: getValueFromSearchParams(params, "approver", "users/"),- releaser: getValueFromSearchParams(params, "releaser", "users/"),+ approver: getValueFromSearchParams(params, "approver", userNamePrefix),+ releaser: getValueFromSearchParams(params, "releaser", userNamePrefix),};return uiIssueFilter;diff --git a/frontend/src/utils/v1/advanced-search/issue/utils.ts b/frontend/src/utils/v1/advanced-search/issue/utils.tsindex 9a4804d539..7cd7e29ebc 100644--- a/frontend/src/utils/v1/advanced-search/issue/utils.ts+++ b/frontend/src/utils/v1/advanced-search/issue/utils.ts@@ -1,4 +1,10 @@import { useDatabaseV1Store } from "@/store";+import {+ environmentNamePrefix,+ instanceNamePrefix,+ userNamePrefix,+ projectNamePrefix,+} from "@/store";import type { IssueFilter } from "@/types";import { unknownDatabase } from "@/types";import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";@@ -40,13 +46,13 @@ export const buildIssueFilterBySearchParams = (const filter: IssueFilter = {...defaultFilter,query,- instance: getValueFromSearchParams(params, "instance", "instances/"),+ instance: getValueFromSearchParams(params, "instance", instanceNamePrefix),database,- project: `projects/${projectScope?.value ?? "-"}`,+ project: `${projectNamePrefix}${projectScope?.value ?? "-"}`,createdTsAfter: createdTsRange?.[0],createdTsBefore: createdTsRange?.[1],taskType: taskTypeScope?.value,- creator: getValueFromSearchParams(params, "creator", "users/"),+ creator: getValueFromSearchParams(params, "creator", userNamePrefix),statusList:status === "OPEN"? [IssueStatus.OPEN]@@ -54,6 +60,11 @@ export const buildIssueFilterBySearchParams = (? [IssueStatus.DONE, IssueStatus.CANCELED]: undefined,labels,+ environment: getValueFromSearchParams(+ params,+ "environment",+ environmentNamePrefix+ ),};return filter;};diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex e97a8c5424..fd67934b22 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -4111,14 +4111,15 @@ paths:- task_type: support "==" operator, the value can be "DDL", "DML" or "DATA_EXPORT"- instance: the instance full name in the "instances/{id}" format, support "==" operator.- database: the database full name in the "instances/{id}/databases/{name}" format, support "==" operator.+ - environment: the database full name in the "environments/{name}" format, support "==" operator.- labels: the issue labels, support "==" and "in" operator.- - has_pipeline: the issue has pipeline or not, support "==" operator, the value should be "true" or "false".For example:creator == "users/[email protected]" && status in ["OPEN", "DONE"]status == "CANCELED" && type == "DATABASE_CHANGE"instance == "instances/sample" && labels in ["label1", "label2"]- has_pipeline == true && create_time >= "2025-01-02T15:04:05Z07:00"+ create_time >= "2025-01-02T15:04:05Z07:00"+ environment == "environments/test"schema:type: string- name: querydiff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex da979014fc..c99c4a82f2 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -3742,9 +3742,9 @@ When paginating, all other parameters provided to `ListIssueComments` must matchWhen paginating, all other parameters provided to `ListIssues` must match the call that provided the page token. || filter | [string](#string) | | Filter is used to filter issues returned in the list. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec-Supported filters: - creator: issue creator full name in "users/{email or id}" format, support "==" operator. - status: the issue status, support "==" and "in" operator, check the IssueStatus enum for the values. - create_time: issue create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator. - type: the issue type, support "==" and "in" operator, check the Type enum in the Issue message for the values. - task_type: support "==" operator, the value can be "DDL", "DML" or "DATA_EXPORT" - instance: the instance full name in the "instances/{id}" format, support "==" operator. - database: the database full name in the "instances/{id}/databases/{name}" format, support "==" operator. - labels: the issue labels, support "==" and "in" operator. - has_pipeline: the issue has pipeline or not, support "==" operator, the value should be "true" or "false".+Supported filters: - creator: issue creator full name in "users/{email or id}" format, support "==" operator. - status: the issue status, support "==" and "in" operator, check the IssueStatus enum for the values. - create_time: issue create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator. - type: the issue type, support "==" and "in" operator, check the Type enum in the Issue message for the values. - task_type: support "==" operator, the value can be "DDL", "DML" or "DATA_EXPORT" - instance: the instance full name in the "instances/{id}" format, support "==" operator. - database: the database full name in the "instances/{id}/databases/{name}" format, support "==" operator. - environment: the database full name in the "environments/{name}" format, support "==" operator. - labels: the issue labels, support "==" and "in" operator.-For example: creator == "users/[email protected]" && status in ["OPEN", "DONE"] status == "CANCELED" && type == "DATABASE_CHANGE" instance == "instances/sample" && labels in ["label1", "label2"] has_pipeline == true && create_time >= "2025-01-02T15:04:05Z07:00" |+For example: creator == "users/[email protected]" && status in ["OPEN", "DONE"] status == "CANCELED" && type == "DATABASE_CHANGE" instance == "instances/sample" && labels in ["label1", "label2"] create_time >= "2025-01-02T15:04:05Z07:00" environment == "environments/test" || query | [string](#string) | | Query is the query statement. |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex f3e87c4fb6..555593570e 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -11316,14 +11316,15 @@ Supported filters:- task_type: support "==" operator, the value can be "DDL", "DML" or "DATA_EXPORT"- instance: the instance full name in the "instances/{id}" format, support "==" operator.- database: the database full name in the "instances/{id}/databases/{name}" format, support "==" operator.+- environment: the database full name in the "environments/{name}" format, support "==" operator.- labels: the issue labels, support "==" and "in" operator.-- has_pipeline: the issue has pipeline or not, support "==" operator, the value should be "true" or "false".For example:creator == "users/[email protected]" && status in ["OPEN", "DONE"]status == "CANCELED" && type == "DATABASE_CHANGE"instance == "instances/sample" && labels in ["label1", "label2"]-has_pipeline == true && create_time >= "2025-01-02T15:04:05Z07:00" </p></td>+create_time >= "2025-01-02T15:04:05Z07:00"+environment == "environments/test" </p></td></tr><tr>diff --git a/proto/v1/v1/issue_service.proto b/proto/v1/v1/issue_service.protoindex 99d42c6b11..d6ad7f4f5f 100644--- a/proto/v1/v1/issue_service.proto+++ b/proto/v1/v1/issue_service.proto@@ -202,14 +202,15 @@ message ListIssuesRequest {// - task_type: support "==" operator, the value can be "DDL", "DML" or "DATA_EXPORT"// - instance: the instance full name in the "instances/{id}" format, support "==" operator.// - database: the database full name in the "instances/{id}/databases/{name}" format, support "==" operator.+ // - environment: the database full name in the "environments/{name}" format, support "==" operator.// - labels: the issue labels, support "==" and "in" operator.- // - has_pipeline: the issue has pipeline or not, support "==" operator, the value should be "true" or "false".//// For example:// creator == "users/[email protected]" && status in ["OPEN", "DONE"]// status == "CANCELED" && type == "DATABASE_CHANGE"// instance == "instances/sample" && labels in ["label1", "label2"]- // has_pipeline == true && create_time >= "2025-01-02T15:04:05Z07:00"+ // create_time >= "2025-01-02T15:04:05Z07:00"+ // environment == "environments/test"string filter = 4;// Query is the query statement.