feat: add suite_status filter for cloud drift tests#210
feat: add suite_status filter for cloud drift tests#210sohil-kshirsagar wants to merge 1 commit intomainfrom
Conversation
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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| default: | ||
| return nil | ||
| } | ||
| } |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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": |
There was a problem hiding this comment.
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>
| ) | ||
| var all []*backend.TraceTest | ||
| usedStatusFilter := false | ||
| if val, ok := runner.ExtractSuiteStatusFromFilter(filter); ok { |
There was a problem hiding this comment.
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>


Add a
suite_statusfilter that lets users fetch and run cloud tests by theirsuite 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 andpasses it as
status_filterto the backend'sGetAllTraceTestsendpoint (newfield 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
status_filtertoGetAllTraceTestsRequesttusk-drift-schemas#45)