fix(cli): move estimation flag validation before action lookup #1073

Closed
hamza.khyari wants to merge 5 commits from fix/estimation-flag-validation into master
Member

Summary

Fixes the flaky Plan use rejects no-estimate with estimation actor override scenario (cli_extensions.feature:93) that fails intermittently in CI.

Targets: feature/m6-estimation (PR #528 branch)

Root Cause

In plan use, the --no-estimate / --estimation-actor mutual exclusion check (line 1682) ran after service.get_action_by_name() (line 1655). In CI with behave-parallel --processes 24, the unittest.mock.patch on _get_lifecycle_service can race — if the real service is called, it raises ResourceNotFoundError for the test action local/test-action. This is caught by the broad except handler at line 1835, which raises typer.Abort(). The estimation flag conflict message never appears, and the test fails.

Fix

Move all CLI flag validations (actor format checks + mutual exclusion check) before service.get_action_by_name(). Pure input validation should never depend on action lookup or DB state.

Before:                          After:
1. get_action_by_name()          1. validate actor formats
2. build project links           2. check --no-estimate conflict
3. validate actor formats        3. get_action_by_name()
4. check --no-estimate conflict  4. build project links

Verification

  • With the fix, the flag conflict is detected even with no mocks and a nonexistent action name
  • All 59 cli_extensions.feature scenarios pass
  • Lint clean
## Summary Fixes the flaky `Plan use rejects no-estimate with estimation actor override` scenario (`cli_extensions.feature:93`) that fails intermittently in CI. **Targets**: `feature/m6-estimation` (PR #528 branch) ## Root Cause In `plan use`, the `--no-estimate` / `--estimation-actor` mutual exclusion check (line 1682) ran **after** `service.get_action_by_name()` (line 1655). In CI with `behave-parallel --processes 24`, the `unittest.mock.patch` on `_get_lifecycle_service` can race — if the real service is called, it raises `ResourceNotFoundError` for the test action `local/test-action`. This is caught by the broad `except` handler at line 1835, which raises `typer.Abort()`. The estimation flag conflict message never appears, and the test fails. ## Fix Move all CLI flag validations (actor format checks + mutual exclusion check) **before** `service.get_action_by_name()`. Pure input validation should never depend on action lookup or DB state. ``` Before: After: 1. get_action_by_name() 1. validate actor formats 2. build project links 2. check --no-estimate conflict 3. validate actor formats 3. get_action_by_name() 4. check --no-estimate conflict 4. build project links ``` ## Verification - With the fix, the flag conflict is detected even with no mocks and a nonexistent action name - All 59 `cli_extensions.feature` scenarios pass - Lint clean
hamza.khyari changed target branch from feature/m6-estimation to master 2026-03-19 15:06:38 +00:00
hamza.khyari force-pushed fix/estimation-flag-validation from 9d8ec642ff to d1d8ac483f
Some checks failed
CI / lint (pull_request) Successful in 22s
CI / security (pull_request) Successful in 41s
CI / typecheck (pull_request) Successful in 55s
CI / quality (pull_request) Successful in 31s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
CI / unit_tests (pull_request) Failing after 4m6s
CI / docker (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 4m0s
CI / benchmark-regression (pull_request) Failing after 18m51s
CI / coverage (pull_request) Failing after 19m13s
CI / e2e_tests (pull_request) Failing after 19m15s
2026-03-19 15:07:08 +00:00
Compare
hamza.khyari closed this pull request 2026-03-19 15:12:53 +00:00
hamza.khyari deleted branch fix/estimation-flag-validation 2026-03-19 15:13:01 +00:00
Some checks failed
CI / lint (pull_request) Successful in 22s
Required
Details
CI / security (pull_request) Successful in 41s
Required
Details
CI / typecheck (pull_request) Successful in 55s
Required
Details
CI / quality (pull_request) Successful in 31s
Required
Details
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
Required
Details
CI / unit_tests (pull_request) Failing after 4m6s
Required
Details
CI / docker (pull_request) Has been skipped
Required
Details
CI / integration_tests (pull_request) Failing after 4m0s
Required
Details
CI / benchmark-regression (pull_request) Failing after 18m51s
CI / coverage (pull_request) Failing after 19m13s
Required
Details
CI / e2e_tests (pull_request) Failing after 19m15s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!1073
No description provided.