Skip to content

fix(python-cli): allow qualitative goal creation without metric options - #13095

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
devloper961-maker:fix/goal-create-qualitative
Sep 8, 2026
Merged

fix(python-cli): allow qualitative goal creation without metric options#13095
kodjima33 merged 2 commits into
BasedHardware:mainfrom
devloper961-maker:fix/goal-create-qualitative

Conversation

@devloper961-maker

@devloper961-maker devloper961-maker commented Sep 8, 2026

Copy link
Copy Markdown

Problem

omi --json goal create "Build stronger relationships" exits 2 with a missing --target usage error before any HTTP request is sent.

The developer API explicitly supports qualitative goals by omitting all metric fields — CreateGoalRequest in backend/routers/developer.py declares goal_type, target_value, current_value, min_value, max_value as Optional (all default None). The CLI is stricter than the API it wraps, so qualitative goals are impossible to create from the CLI.

Fixes #13085

Root cause

create_goal in sdks/python-cli/omi_cli/commands/goal.py declared --target as required (typer.Option(...)) and always sent every metric field in the request body.

Implementation

  • Make --target, --type, --current, --min, --max optional (Optional[float] / Optional[GoalType], default None).
  • If no metric option is provided, send only {"title": ...} — a qualitative goal, exactly what the API accepts.
  • If any metric option is provided, preserve the historical defaults (type=scale, current=0, min=0, max=10) so existing scripts behave identically.
  • Validate metric combinations (cubic review follow-up):
    • --unit without any metric option is rejected (exit 1) — the backend only persists unit on metric-backed goals, so it would be silently dropped on a qualitative goal.
    • Metric options without --target are rejected (exit 1) — preserving the historical contract that every metric goal has a target, instead of fabricating a target-less scale goal.
  • --unit continues to be attached whenever provided alongside a metric goal.

Testing

  • New: test_goal_create_qualitative_omits_metrics — qualitative request body contains only the title.
  • New: test_goal_create_metric_defaults_preserved--target 2 alone still produces the historical scale defaults (backward compat).
  • New: test_goal_create_unit_without_metrics_rejected--unit alone exits 1 with guidance.
  • New: test_goal_create_partial_metrics_rejected--current 5 without --target exits 1 with guidance.
  • New: test_goal_create_unit_attached_to_metric_goal--target 2 --unit liters sends unit through.
  • Full Python CLI suite: 134 passed, 1 skipped.
  • The 4 failures in tests/test_openapi_contract.py on older runs are pre-existing on current main and unrelated to this change.
  • black clean on both touched files.

Compatibility

No breaking change for valid invocations: every command that worked before produces the same request body. The only behavior changes are that omitting metric options now succeeds (qualitative goal) instead of exiting with a usage error, and previously broken partial-metric invocations now fail fast with a clear client-side message instead of creating a malformed goal server-side.

Review in cubic

The developer API (backend/routers/developer.py CreateGoalRequest) supports
goals with all metric fields omitted (qualitative goals), but the CLI's
'omi goal create' required --target, exiting 2 with a usage error before any
HTTP request. This made qualitative goals impossible from the CLI.

Make --target/--type/--current/--min/--max optional. When no metric option
is provided, send only the title (qualitative goal). When any metric option
is provided, keep the historical defaults (type=scale, current=0, min=0,
max=10) so existing scripts behave exactly as before.

Fixes BasedHardware#13085

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread sdks/python-cli/omi_cli/commands/goal.py Outdated
Comment thread sdks/python-cli/omi_cli/commands/goal.py Outdated
Address cubic review findings on BasedHardware#13095: --unit without any metric flag
was silently dropped by the backend for qualitative goals, and partial
metric options without --target fabricated a target-less scale goal.
Both now exit 1 with clear guidance; --target is always sent when a
metric goal is requested.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@devloper961-maker

Copy link
Copy Markdown
Author

Both review findings are fixed in daf249e:

  1. --unit without metric flags — now rejected client-side with exit 1 ("--unit requires a metric goal") instead of silently sending a unit the backend drops for qualitative goals. The --unit help text documents the requirement.

  2. Metric options without --target — now rejected client-side with exit 1 ("--target is required when using metric options"). This preserves the historical contract where --target was mandatory for every metric goal and prevents the fabricated target-less scale goal (_safe_float(None, 0.0) in backend/database/goals.py would have coerced target_value=None to 0.0). This also matches the scope stated in Python CLI rejects qualitative goal creation supported by the API #13085 ("rejecting other metric options without a target").

New tests: test_goal_create_unit_without_metrics_rejected, test_goal_create_partial_metrics_rejected, test_goal_create_unit_attached_to_metric_goal. Full CLI suite: 134 passed; black clean.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Real bug: CLI requires --target even though the backend's CreateGoalRequest supports qualitative goals with no metric fields. Confirmed --target still required on main. Scoped fix (130 loc) with 5 new tests covering both qualitative and backward-compat metric paths. Confidence 5/5.

@kodjima33
kodjima33 merged commit d6aa421 into BasedHardware:main Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python CLI rejects qualitative goal creation supported by the API

2 participants