Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: issue search params (#17523)

ecmadao0491ace42425
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index 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.InstanceID
issueFind.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.go
index 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.go
index 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 *string
DatabaseName *string
+ // Should match the task environment.
+ EnvironmentID *string
// If specified, then it will only fetch "Limit" most recently updated issues
Limit *int
Offset *int
@@ -326,6 +328,10 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
where = 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.vue
index 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.vue
index 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.vue
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.yaml
index 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: query
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 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 match
When 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 &#34;users/{email or id}&#34; format, support &#34;==&#34; operator. - status: the issue status, support &#34;==&#34; and &#34;in&#34; operator, check the IssueStatus enum for the values. - create_time: issue create time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator. - type: the issue type, support &#34;==&#34; and &#34;in&#34; operator, check the Type enum in the Issue message for the values. - task_type: support &#34;==&#34; operator, the value can be &#34;DDL&#34;, &#34;DML&#34; or &#34;DATA_EXPORT&#34; - instance: the instance full name in the &#34;instances/{id}&#34; format, support &#34;==&#34; operator. - database: the database full name in the &#34;instances/{id}/databases/{name}&#34; format, support &#34;==&#34; operator. - labels: the issue labels, support &#34;==&#34; and &#34;in&#34; operator. - has_pipeline: the issue has pipeline or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;.
+Supported filters: - creator: issue creator full name in &#34;users/{email or id}&#34; format, support &#34;==&#34; operator. - status: the issue status, support &#34;==&#34; and &#34;in&#34; operator, check the IssueStatus enum for the values. - create_time: issue create time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator. - type: the issue type, support &#34;==&#34; and &#34;in&#34; operator, check the Type enum in the Issue message for the values. - task_type: support &#34;==&#34; operator, the value can be &#34;DDL&#34;, &#34;DML&#34; or &#34;DATA_EXPORT&#34; - instance: the instance full name in the &#34;instances/{id}&#34; format, support &#34;==&#34; operator. - database: the database full name in the &#34;instances/{id}/databases/{name}&#34; format, support &#34;==&#34; operator. - environment: the database full name in the &#34;environments/{name}&#34; format, support &#34;==&#34; operator. - labels: the issue labels, support &#34;==&#34; and &#34;in&#34; operator.
-For example: creator == &#34;users/[email protected]&#34; &amp;&amp; status in [&#34;OPEN&#34;, &#34;DONE&#34;] status == &#34;CANCELED&#34; &amp;&amp; type == &#34;DATABASE_CHANGE&#34; instance == &#34;instances/sample&#34; &amp;&amp; labels in [&#34;label1&#34;, &#34;label2&#34;] has_pipeline == true &amp;&amp; create_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34; |
+For example: creator == &#34;users/[email protected]&#34; &amp;&amp; status in [&#34;OPEN&#34;, &#34;DONE&#34;] status == &#34;CANCELED&#34; &amp;&amp; type == &#34;DATABASE_CHANGE&#34; instance == &#34;instances/sample&#34; &amp;&amp; labels in [&#34;label1&#34;, &#34;label2&#34;] create_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34; environment == &#34;environments/test&#34; |
| 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.html
index 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 &#34;==&#34; operator, the value can be &#34;DDL&#34;, &#34;DML&#34; or &#34;DATA_EXPORT&#34;
- instance: the instance full name in the &#34;instances/{id}&#34; format, support &#34;==&#34; operator.
- database: the database full name in the &#34;instances/{id}/databases/{name}&#34; format, support &#34;==&#34; operator.
+- environment: the database full name in the &#34;environments/{name}&#34; format, support &#34;==&#34; operator.
- labels: the issue labels, support &#34;==&#34; and &#34;in&#34; operator.
-- has_pipeline: the issue has pipeline or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;.
For example:
creator == &#34;users/[email protected]&#34; &amp;&amp; status in [&#34;OPEN&#34;, &#34;DONE&#34;]
status == &#34;CANCELED&#34; &amp;&amp; type == &#34;DATABASE_CHANGE&#34;
instance == &#34;instances/sample&#34; &amp;&amp; labels in [&#34;label1&#34;, &#34;label2&#34;]
-has_pipeline == true &amp;&amp; create_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34; </p></td>
+create_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34;
+environment == &#34;environments/test&#34; </p></td>
</tr>
<tr>
diff --git a/proto/v1/v1/issue_service.proto b/proto/v1/v1/issue_service.proto
index 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.