-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement unknown flag detection and enhance search result messaging #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
843ba0d
a4205bd
5c631ce
be5b057
870c433
f3f801d
3f2b982
87baae6
712e25f
d9764bc
8330c5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,46 @@ import { resolveTenantId } from '../config.ts'; | |||||||||||||||||
|
|
||||||||||||||||||
| export type SearchResult = { items: Array<Record<string, unknown>>; total?: number }; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Flags that are valid globally (not specific to any search resource). | ||||||||||||||||||
| */ | ||||||||||||||||||
| export const GLOBAL_FLAGS = new Set([ | ||||||||||||||||||
| 'profile', 'sortBy', 'asc', 'desc', 'help', 'version', 'limit', | ||||||||||||||||||
| ]); | ||||||||||||||||||
|
Comment on lines
+15
to
+17
|
||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Valid search filter flags per resource (values keys that are consumed by the search handler). | ||||||||||||||||||
| * This map is used to detect when a user passes a flag that looks valid but is not recognized | ||||||||||||||||||
| * for the specific resource, causing silent filter drops. | ||||||||||||||||||
| */ | ||||||||||||||||||
| export const SEARCH_RESOURCE_FLAGS: Record<string, Set<string>> = { | ||||||||||||||||||
| 'process-definition': new Set(['bpmnProcessId', 'id', 'processDefinitionId', 'name', 'key', 'iid', 'iname']), | ||||||||||||||||||
|
||||||||||||||||||
| 'process-definition': new Set(['bpmnProcessId', 'id', 'processDefinitionId', 'name', 'key', 'iid', 'iname']), | |
| 'process-definition': new Set(['bpmnProcessId', 'id', 'processDefinitionId', 'name', 'key', 'iid', 'iname', 'version_num']), |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing flag in SEARCH_RESOURCE_FLAGS: The search process definitions handler in index.ts (line 680) accepts version_num flag, but 'version_num' is not included in SEARCH_RESOURCE_FLAGS['process-definition']. This will cause detectUnknownSearchFlags to incorrectly report it as an unknown flag if a user tries to use it. Add 'version_num' to the process-definition flag set.
| 'process-definition': new Set(['bpmnProcessId', 'id', 'processDefinitionId', 'name', 'key', 'iid', 'iname']), | |
| 'process-definition': new Set(['bpmnProcessId', 'id', 'processDefinitionId', 'name', 'key', 'iid', 'iname', 'version_num']), |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SEARCH_RESOURCE_FLAGS is missing flags that are actually supported by the corresponding search handlers, so users will get false "unknown flag" warnings. For example, searchProcessInstances/searchUserTasks/searchJobs accept --between and --dateField, and searchIncidents accepts --between, but none of these appear in the per-resource sets. Add the missing flags to the appropriate resource entries so detectUnknownSearchFlags() doesn’t warn on documented options.
| 'process-instance': new Set(['bpmnProcessId', 'id', 'processDefinitionId', 'processDefinitionKey', 'state', 'key', 'parentProcessInstanceKey', 'iid']), | |
| 'user-task': new Set(['state', 'assignee', 'processInstanceKey', 'processDefinitionKey', 'elementId', 'iassignee']), | |
| 'incident': new Set(['state', 'processInstanceKey', 'processDefinitionKey', 'bpmnProcessId', 'id', 'processDefinitionId', 'errorType', 'errorMessage', 'ierrorMessage', 'iid']), | |
| 'jobs': new Set(['state', 'type', 'processInstanceKey', 'processDefinitionKey', 'itype']), | |
| 'process-instance': new Set(['bpmnProcessId', 'id', 'processDefinitionId', 'processDefinitionKey', 'state', 'key', 'parentProcessInstanceKey', 'iid', 'between', 'dateField']), | |
| 'user-task': new Set(['state', 'assignee', 'processInstanceKey', 'processDefinitionKey', 'elementId', 'iassignee', 'between', 'dateField']), | |
| 'incident': new Set(['state', 'processInstanceKey', 'processDefinitionKey', 'bpmnProcessId', 'id', 'processDefinitionId', 'errorType', 'errorMessage', 'ierrorMessage', 'iid', 'between']), | |
| 'jobs': new Set(['state', 'type', 'processInstanceKey', 'processDefinitionKey', 'itype', 'between', 'dateField']), |
vobu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,7 @@ import { | |||||
| searchIncidents, | ||||||
| searchJobs, | ||||||
| searchVariables, | ||||||
| detectUnknownSearchFlags, | ||||||
| } from './commands/search.ts'; | ||||||
| import { listUserTasks, completeUserTask } from './commands/user-tasks.ts'; | ||||||
| import { listIncidents, getIncident, resolveIncident } from './commands/incidents.ts'; | ||||||
|
|
@@ -142,6 +143,17 @@ function resolveProcessDefinitionId(values: any): string | undefined { | |||||
| return (values.id || values.processDefinitionId || values.bpmnProcessId) as string | undefined; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Warn about unrecognized flags for a search resource. | ||||||
| */ | ||||||
| function warnUnknownSearchFlags(logger: ReturnType<typeof getLogger>, unknownFlags: string[], resource: string): void { | ||||||
| if (unknownFlags.length === 0) return; | ||||||
| const flagList = unknownFlags.map(f => `--${f}`).join(', '); | ||||||
| logger.warn( | ||||||
| `Flag(s) ${flagList} not recognized for 'search ${resource}'. They will be ignored. Run "c8ctl help search" for valid options.`, | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Main CLI handler | ||||||
| */ | ||||||
|
|
@@ -657,33 +669,37 @@ async function main() { | |||||
| // Handle search commands | ||||||
| if (verb === 'search') { | ||||||
| const normalizedSearchResource = normalizeResource(resource); | ||||||
| const unknownFlags = detectUnknownSearchFlags(values as Record<string, unknown>, normalizedSearchResource); | ||||||
| warnUnknownSearchFlags(logger, unknownFlags, resource); | ||||||
|
|
||||||
| if (normalizedSearchResource === 'process-definition' || normalizedSearchResource === 'process-definitions') { | ||||||
| await searchProcessDefinitions({ | ||||||
| profile: values.profile as string | undefined, | ||||||
| processDefinitionId: values.bpmnProcessId as string | undefined, | ||||||
| processDefinitionId: resolveProcessDefinitionId(values), | ||||||
| name: values.name as string | undefined, | ||||||
| version: (values.version_num && typeof values.version_num === 'string') ? parseInt(values.version_num) : undefined, | ||||||
|
||||||
| version: (values.version_num && typeof values.version_num === 'string') ? parseInt(values.version_num) : undefined, | |
| version: (values.version && typeof values.version === 'string') ? parseInt(values.version) : undefined, |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
values.version is being parsed as the process-definition filter version. This conflicts with the documented global --version/-v flag (intended to show CLI version) and also makes detectUnknownSearchFlags() treat version as globally valid (so search <other-resource> --version ... won’t be warned about). Consider introducing a dedicated filter flag (e.g. --processDefinitionVersion) and keeping --version as a boolean global flag; also validate the parsed number (avoid passing NaN).
Uh oh!
There was an error while loading. Please reload this page.