Skip to content

feat: add suite_status filter for cloud drift tests#210

Open
sohil-kshirsagar wants to merge 1 commit intomainfrom
feat/suite-status-filter
Open

feat: add suite_status filter for cloud drift tests#210
sohil-kshirsagar wants to merge 1 commit intomainfrom
feat/suite-status-filter

Conversation

@sohil-kshirsagar
Copy link
Contributor

Add a suite_status filter that lets users fetch and run cloud tests by their
suite status (draft or in_suite), e.g. tusk drift run --cloud -f 'suite_status=draft'.

Why

Today, draft tests are only fetchable through the validation endpoint. There's no
way to run just draft tests to sanity-check them before they get promoted to the
suite. This unblocks that workflow without requiring --validate-suite.

How it works

When the CLI detects suite_status= in the filter, it pre-parses the value and
passes it as status_filter to the backend's GetAllTraceTests endpoint (new
field from drift-schemas v0.1.32). This bypasses the ID-based cache path since
that only fetches IN_SUITE test IDs. When no suite_status filter is set, behavior
is unchanged.

Dependencies

Add a suite_status filter field that allows users to fetch and run
draft tests from the cloud without going through validation mode.

When --filter suite_status=draft is set, the CLI bypasses the cache
and passes the status filter directly to GetAllTraceTests on the
backend. This works for both `drift run` and `drift list`.

Also bumps tusk-drift-schemas to v0.1.32 for the new status_filter
field on GetAllTraceTestsRequest.
@sohil-kshirsagar sohil-kshirsagar requested a review from jy-tan March 25, 2026 05:50
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

default:
return nil
}
}
Copy link

Choose a reason for hiding this comment

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

Case-insensitive server filter vs case-sensitive client regex

Medium Severity

ParseTraceTestStatusFilter uses strings.ToLower to accept case-insensitive input (e.g., "DRAFT"), correctly fetching draft tests from the server. However, the same original-case value is also used as a regex in the client-side FilterTests call, where it's matched against the lowercase SuiteStatus field ("draft" from protoTraceTestStatusToString). Since Go regex is case-sensitive, suite_status=DRAFT correctly fetches draft tests from the backend but then filters them all out on the client side, returning an empty result.

Additional Locations (2)
Fix in Cursor Fix in Web

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 12 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/runner/filter.go">

<violation number="1" location="internal/runner/filter.go:160">
P1: `ParseTraceTestStatusFilter` normalizes to lowercase via `strings.ToLower` for the backend fetch, but the same user-provided value (e.g., `DRAFT`) is kept as-is in the filter string passed to `FilterTests`. Since `SuiteStatus` on the `Test` struct is always lowercase (`"draft"`, `"in_suite"` from `protoTraceTestStatusToString`), and Go regex is case-sensitive, a filter like `suite_status=DRAFT` will correctly fetch draft tests from the server but then filter them all out on the client side, returning zero results.

Either normalize the `suite_status` filter value to lowercase before client-side filtering, or use a case-insensitive regex (e.g., `(?i)` prefix) for the `suite_status` field.</violation>
</file>

<file name="cmd/list.go">

<violation number="1" location="cmd/list.go:99">
P2: `suite_status` regex values silently fall back to the cache path, which only returns IN_SUITE tests, so valid filter forms (for example `suite_status=^draft$`) can miss draft tests.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

return t.TraceID
case "file":
return t.FileName
case "suite_status":
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 25, 2026

Choose a reason for hiding this comment

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

P1: ParseTraceTestStatusFilter normalizes to lowercase via strings.ToLower for the backend fetch, but the same user-provided value (e.g., DRAFT) is kept as-is in the filter string passed to FilterTests. Since SuiteStatus on the Test struct is always lowercase ("draft", "in_suite" from protoTraceTestStatusToString), and Go regex is case-sensitive, a filter like suite_status=DRAFT will correctly fetch draft tests from the server but then filter them all out on the client side, returning zero results.

Either normalize the suite_status filter value to lowercase before client-side filtering, or use a case-insensitive regex (e.g., (?i) prefix) for the suite_status field.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/runner/filter.go, line 160:

<comment>`ParseTraceTestStatusFilter` normalizes to lowercase via `strings.ToLower` for the backend fetch, but the same user-provided value (e.g., `DRAFT`) is kept as-is in the filter string passed to `FilterTests`. Since `SuiteStatus` on the `Test` struct is always lowercase (`"draft"`, `"in_suite"` from `protoTraceTestStatusToString`), and Go regex is case-sensitive, a filter like `suite_status=DRAFT` will correctly fetch draft tests from the server but then filter them all out on the client side, returning zero results.

Either normalize the `suite_status` filter value to lowercase before client-side filtering, or use a case-insensitive regex (e.g., `(?i)` prefix) for the `suite_status` field.</comment>

<file context>
@@ -155,6 +157,8 @@ func getFieldValueForFilter(t Test, field string) string {
 		return t.TraceID
 	case "file":
 		return t.FileName
+	case "suite_status":
+		return t.SuiteStatus
 	default:
</file context>
Fix with Cubic

)
var all []*backend.TraceTest
usedStatusFilter := false
if val, ok := runner.ExtractSuiteStatusFromFilter(filter); ok {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 25, 2026

Choose a reason for hiding this comment

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

P2: suite_status regex values silently fall back to the cache path, which only returns IN_SUITE tests, so valid filter forms (for example suite_status=^draft$) can miss draft tests.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At cmd/list.go, line 99:

<comment>`suite_status` regex values silently fall back to the cache path, which only returns IN_SUITE tests, so valid filter forms (for example `suite_status=^draft$`) can miss draft tests.</comment>

<file context>
@@ -93,14 +94,26 @@ func listTests(cmd *cobra.Command, args []string) error {
-		)
+		var all []*backend.TraceTest
+		usedStatusFilter := false
+		if val, ok := runner.ExtractSuiteStatusFromFilter(filter); ok {
+			if statusFilter := runner.ParseTraceTestStatusFilter(val); statusFilter != nil {
+				all, err = api.FetchAllTraceTests(context.Background(), client, authOptions, cfg.Service.ID, &api.FetchAllTraceTestsOptions{
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant