feat: add --name filter to automations list (CLI / SDK / MCP / tRPC)#3952
feat: add --name filter to automations list (CLI / SDK / MCP / tRPC)#3952saddlepaddle merged 3 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughAdd optional case-insensitive name filtering to automation listing: CLI accepts Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant CLI as CLI
participant SDK as SDK
participant MCP as MCP Server
participant DB as Database
CLI->>SDK: Automations.list({ name: "foo" })
SDK->>MCP: RPC "automation.list" params { name: "foo" }
MCP->>DB: SELECT ... WHERE org_id = ? AND name ILIKE '%foo%' (escaped)
DB-->>MCP: rows[]
MCP-->>SDK: rows[]
SDK-->>CLI: rows[]
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryAdds a Confidence Score: 5/5Safe to merge — small, well-scoped change with no logic errors or safety risks.
No files require special attention.
|
| Filename | Overview |
|---|---|
| packages/cli/src/commands/automations/list/command.ts | Adds --name/-n flag for case-insensitive client-side substring filtering; logic is correct, name is non-null in the DB schema so no null-safety risk |
Sequence Diagram
sequenceDiagram
actor User
participant CLI
participant API as tRPC API (automation.list)
User->>CLI: superset automations list [--name "sales"] [--quiet]
CLI->>API: automation.list.query()
API-->>CLI: all automations[]
alt --name provided
CLI->>CLI: filter rows where name.toLowerCase().includes(needle)
end
alt --quiet
CLI-->>User: one ID per line
else table display
CLI-->>User: formatted table (id, name, agent, schedule, enabled, nextRun)
end
Reviews (1): Last reviewed commit: "feat(cli): add --name filter to `automat..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/cli/src/commands/automations/list/command.ts`:
- Around line 12-16: The filter currently calls row.name.toLowerCase() which
will throw for missing/non-string names; update the run method's filtering logic
(where rows.filter is used after ctx.api.automation.list.query and options.name)
to first check typeof row.name === "string" (or coerce with String(row.name)
safely) before calling toLowerCase, e.g. only include rows where typeof row.name
=== "string" && row.name.toLowerCase().includes(needle) so the command won't
crash on partially populated rows.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ed52cc47-519d-4db2-bdef-5ad96f0256fd
📒 Files selected for processing (1)
packages/cli/src/commands/automations/list/command.ts
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
a4d54ec to
9f87743
Compare
Finding an automation's UUID previously required dumping the whole list and grepping the JSON. Add a case-insensitive substring filter on `name` so `automations list --name "sales"` (or `-n sales`) narrows the output. Pairs with `--quiet` for ID-only output: superset automations list -n sales --quiet Filtering happens client-side; the org-scoped list is small.
Add an optional `name` substring filter to `automations.list()` in the SDK and to the `automations_list` MCP v2 tool, matching the CLI's `--name` flag. Filtering happens client-side since the underlying tRPC query takes no params.
9f87743 to
0665e6f
Compare
Move the `--name` substring match from client-side filtering to a `name?: string` input on `automation.list`, applied as `ilike` against the DB. CLI / SDK / MCP v2 now pass the filter through instead of filtering the response, so it scales to teams with hundreds of automations.
automations listThere was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/mcp-v2/src/tools/automations/list.ts`:
- Around line 11-23: The inputSchema currently allows empty strings which the
handler then treats as no filter and returns all automations; update the schema
for inputSchema.name to reject blank/whitespace-only values (e.g. use
z.string().trim().min(1).optional() or an equivalent non-empty string/refine) so
that handler logic using input.name and caller.automation.list only runs when a
real name is provided and empty inputs are rejected at the tool boundary; keep
the handler (createMcpCaller and caller.automation.list) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 97fa66f8-9878-41f0-b867-a3378c008155
📒 Files selected for processing (4)
packages/cli/src/commands/automations/list/command.tspackages/mcp-v2/src/tools/automations/list.tspackages/sdk/src/resources/automations.tspackages/trpc/src/router/automation/automation.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/sdk/src/resources/automations.ts
- packages/cli/src/commands/automations/list/command.ts
| inputSchema: { | ||
| name: z | ||
| .string() | ||
| .optional() | ||
| .describe( | ||
| "Filter rows by case-insensitive substring match on automation name.", | ||
| ), | ||
| }, | ||
| handler: async (input, ctx) => { | ||
| const caller = createMcpCaller(ctx); | ||
| return await caller.automation.list(); | ||
| return await caller.automation.list( | ||
| input.name ? { name: input.name } : undefined, | ||
| ); |
There was a problem hiding this comment.
Reject blank names at the tool boundary.
inputSchema currently accepts "", and the handler turns that into an unfiltered list request. That means a typo or empty default can silently return every automation instead of surfacing invalid input. Make the MCP schema reject blank values so it matches the TRPC contract.
Suggested fix
- inputSchema: {
- name: z
- .string()
- .optional()
- .describe(
- "Filter rows by case-insensitive substring match on automation name.",
- ),
- },
+ inputSchema: {
+ name: z
+ .string()
+ .trim()
+ .min(1)
+ .optional()
+ .describe(
+ "Filter rows by case-insensitive substring match on automation name.",
+ ),
+ },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| inputSchema: { | |
| name: z | |
| .string() | |
| .optional() | |
| .describe( | |
| "Filter rows by case-insensitive substring match on automation name.", | |
| ), | |
| }, | |
| handler: async (input, ctx) => { | |
| const caller = createMcpCaller(ctx); | |
| return await caller.automation.list(); | |
| return await caller.automation.list( | |
| input.name ? { name: input.name } : undefined, | |
| ); | |
| inputSchema: { | |
| name: z | |
| .string() | |
| .trim() | |
| .min(1) | |
| .optional() | |
| .describe( | |
| "Filter rows by case-insensitive substring match on automation name.", | |
| ), | |
| }, | |
| handler: async (input, ctx) => { | |
| const caller = createMcpCaller(ctx); | |
| return await caller.automation.list( | |
| input.name ? { name: input.name } : undefined, | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/mcp-v2/src/tools/automations/list.ts` around lines 11 - 23, The
inputSchema currently allows empty strings which the handler then treats as no
filter and returns all automations; update the schema for inputSchema.name to
reject blank/whitespace-only values (e.g. use
z.string().trim().min(1).optional() or an equivalent non-empty string/refine) so
that handler logic using input.name and caller.automation.list only runs when a
real name is provided and empty inputs are rejected at the tool boundary; keep
the handler (createMcpCaller and caller.automation.list) unchanged.
Bundles the 5 feat(cli) commits since v0.2.2: - automations + tasks alignment with SDK and MCP-v2 (#3966) - cross-device login via OAuth code + PKCE (#3965) - 'automations prompt' split into 'prompt get' / 'prompt set' (#3959) - --name filter on automations list (#3952) - --assignee filter on tasks list (#3972) Push cli-v0.2.3 after this lands to fire the release pipeline.
npm has alpha.6 as the most recent published; alpha.7 was bumped in 71bf008 but never `npm publish`-ed. Skip alpha.7 on the registry and ship the current repo state as alpha.8. Changes since alpha.6: - workspaces.create adopts the canonical host-service shape (#3893) - automations.list accepts --name filter (#3952) - automations.prompt split into automations.prompt.get / .set (#3959) - agents.list (presets demoted to UI-only configuration) (#4097) - agents.run / workspaces.create gain `superset-chat` agent + `kind` discriminator on launch results (terminal vs chat) (#4116) - type adjustments for v2 workspace render path (#4141) - redact x-api-key in debug-log header dumps (#3956, was alpha.7) After merge: `cd packages/sdk && bun run build && cd dist && npm publish --access public`.
Summary
Add
name?: stringfilter toautomation.listacross every surface, applied at the DB layer viailike:superset automations list --name <substring>(alias-n). Pairs with--quietfor ID-only output.automations.list({ name })automations_listtool now takes optionalnameautomation.listaccepts an optional{ name }input and applies it asilike(automations.name, '%...%')in the org-scoped queryWhy this instead of name-as-positional-arg
Task 60e7984c originally proposed making each
automations <subcommand> <id>positional accept a name. The catch: automation names aren't unique (the org has had twoTriage Linearalready). Resolution-on-positional bakes a fragile assumption into seven subcommands and forces an error-on-ambiguity fallback. Alist --namefilter respects the non-uniqueness directly and pairs cleanly with--quietfor scripting, which was the original irritation ("had to grep through ~50 entries of JSON").Why DB-side, not client-side
Initial implementation filtered client-side in each surface. That doesn't scale to teams with hundreds of automations — every list call would still ship the full set over the wire. Pushing the filter into the tRPC query keeps payloads small and lets each surface stay a thin pass-through.
Verification
superset automations list --name "sales"→ narrows to the 3 Sales automationssuperset automations list -n sales --quiet→ 3 UUIDs, one per linesuperset automations list --name "no-such-thing"→ empty, exits 0 (grep-like)superset automations list→ unchanged, returns allsuperset automations list --help→ shows the new flagFollow-ups (not in this PR)
--namefilter onprojects list,workspaces list,tasks list(tasks already has--search),hosts list.Test plan
@superset/trpc,@superset/sdk,@superset/mcp-v2,@superset/cli)Summary by CodeRabbit
New Features
Bug Fixes