Skip to content

fix: --between flag incorrectly flagged as unrecognized for all search commands#112

Merged
vobu merged 2 commits intomainfrom
copilot/fix-between-flag-issue
Feb 27, 2026
Merged

fix: --between flag incorrectly flagged as unrecognized for all search commands#112
vobu merged 2 commits intomainfrom
copilot/fix-between-flag-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

--between and --dateField were absent from GLOBAL_FLAGS, causing detectUnknownSearchFlags() to treat them as unknown for every search resource and emit a spurious warning:

⚠ Flag(s) --between not recognized for 'search process-instance'. They will be ignored.

Changes

  • src/commands/search.ts: Add 'between' and 'dateField' to GLOBAL_FLAGS — these flags apply to all search commands, not any single resource
  • tests/unit/search-feedback.test.ts: Add regression tests verifying neither flag is reported as unknown for any search resource
Original prompt

This section details on the original issue you should resolve

<issue_title>flag --between not recoginzed for any search command</issue_title>
<issue_description>this error message occurs for all resources:
⚠ Flag(s) --between not recognized for 'search '. They will be ignored. Run "c8ctl help search" for valid options.

investigate thoroughly and fix. also look into why no tests have caught this?!

</issue_description>

<agent_instructions>go deep on the bug hunt!</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ized for all search commands

Co-authored-by: vobu <6573426+vobu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix --between flag not recognized for search commands fix: --between flag incorrectly flagged as unrecognized for all search commands Feb 27, 2026
@vobu vobu marked this pull request as ready for review February 27, 2026 20:52
Copilot AI review requested due to automatic review settings February 27, 2026 20:52
@vobu vobu merged commit 1f5e1bd into main Feb 27, 2026
9 checks passed
@vobu vobu deleted the copilot/fix-between-flag-issue branch February 27, 2026 20:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a CLI UX bug where valid date-range flags were incorrectly treated as unknown by search commands, causing spurious warnings during c8ctl search … usage.

Changes:

  • Adds between and dateField to the set used by detectUnknownSearchFlags() for global search flag validation.
  • Adds unit tests intended to prevent regressions in unknown-flag detection for --between and --dateField.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/commands/search.ts Extends GLOBAL_FLAGS to include between and dateField so unknown-flag detection doesn’t warn on these flags.
tests/unit/search-feedback.test.ts Adds regression tests asserting --between/--dateField are not reported as unknown.

Comment on lines 15 to 17
export const GLOBAL_FLAGS = new Set([
'profile', 'sortBy', 'asc', 'desc', 'help', 'version',
'profile', 'sortBy', 'asc', 'desc', 'help', 'version', 'between', 'dateField',
]);
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

Adding between and dateField to GLOBAL_FLAGS makes detectUnknownSearchFlags() stop warning about these flags for all search resources, including ones that don't currently support them (e.g. search process-definition and search variable ignore --between, and search incident ignores --dateField). This undermines the purpose of unknown-flag detection by allowing silent filter drops.

Consider instead adding between/dateField to SEARCH_RESOURCE_FLAGS only for the resources whose handlers actually consume them (pi/ut/jobs for both; incidents for between only), or implement support in the remaining handlers + help output if they are meant to be truly global.

Copilot uses AI. Check for mistakes.
Comment on lines +162 to +175
test('--between is not flagged as unknown for any search resource', () => {
const resources = ['process-definition', 'process-instance', 'user-task', 'incident', 'jobs', 'variable'];
for (const resource of resources) {
const unknown = detectUnknownSearchFlags({ between: '2024-01-01..2024-12-31' }, resource);
assert.deepStrictEqual(unknown, [], `--between incorrectly flagged as unknown for '${resource}'`);
}
});

test('--dateField is not flagged as unknown for any search resource', () => {
const resources = ['process-definition', 'process-instance', 'user-task', 'incident', 'jobs', 'variable'];
for (const resource of resources) {
const unknown = detectUnknownSearchFlags({ dateField: 'startDate' }, resource);
assert.deepStrictEqual(unknown, [], `--dateField incorrectly flagged as unknown for '${resource}'`);
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

These regression tests assert that --between/--dateField are never unknown for any search resource, but today several resources don't consume these flags (process-definition, variable, and incident for dateField). With GLOBAL_FLAGS updated, this will now pass while the flags are silently ignored.

Update the test cases to only expect acceptance on resources that actually support the flags (and continue to expect unknown-flag detection for unsupported resources), unless you’re also extending the search handlers/help to make them truly global.

Suggested change
test('--between is not flagged as unknown for any search resource', () => {
const resources = ['process-definition', 'process-instance', 'user-task', 'incident', 'jobs', 'variable'];
for (const resource of resources) {
const unknown = detectUnknownSearchFlags({ between: '2024-01-01..2024-12-31' }, resource);
assert.deepStrictEqual(unknown, [], `--between incorrectly flagged as unknown for '${resource}'`);
}
});
test('--dateField is not flagged as unknown for any search resource', () => {
const resources = ['process-definition', 'process-instance', 'user-task', 'incident', 'jobs', 'variable'];
for (const resource of resources) {
const unknown = detectUnknownSearchFlags({ dateField: 'startDate' }, resource);
assert.deepStrictEqual(unknown, [], `--dateField incorrectly flagged as unknown for '${resource}'`);
}
test('--between is only accepted for resources that support date range filtering', () => {
const resourcesWithBetween = ['process-instance', 'user-task', 'incident', 'jobs'];
const resourcesWithoutBetween = ['process-definition', 'variable'];
for (const resource of resourcesWithBetween) {
const unknown = detectUnknownSearchFlags({ between: '2024-01-01..2024-12-31' }, resource);
assert.deepStrictEqual(
unknown,
[],
`--between incorrectly flagged as unknown for '${resource}' (expected supported)`
);
}
for (const resource of resourcesWithoutBetween) {
const unknown = detectUnknownSearchFlags({ between: '2024-01-01..2024-12-31' }, resource);
assert.deepStrictEqual(
unknown,
['between'],
`--between should be reported as unknown for '${resource}' (expected unsupported)`
);
}
});
test('--dateField is only accepted for resources that support overriding the date field', () => {
const resourcesWithDateField = ['process-instance', 'user-task', 'jobs'];
const resourcesWithoutDateField = ['process-definition', 'variable', 'incident'];
for (const resource of resourcesWithDateField) {
const unknown = detectUnknownSearchFlags({ dateField: 'startDate' }, resource);
assert.deepStrictEqual(
unknown,
[],
`--dateField incorrectly flagged as unknown for '${resource}' (expected supported)`
);
}
for (const resource of resourcesWithoutDateField) {
const unknown = detectUnknownSearchFlags({ dateField: 'startDate' }, resource);
assert.deepStrictEqual(
unknown,
['dateField'],
`--dateField should be reported as unknown for '${resource}' (expected unsupported)`
);
}

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

This has been released in 2.4.1-alpha.1.

@github-actions
Copy link

This has been released in 2.4.1.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flag --between not recoginzed for any search command

3 participants