Skip to content

Various CLI improvements and fixes (and one backend fix)#2264

Merged
LevinCeglie merged 8 commits into
devfrom
feat/cli_improvements
Jun 17, 2026
Merged

Various CLI improvements and fixes (and one backend fix)#2264
LevinCeglie merged 8 commits into
devfrom
feat/cli_improvements

Conversation

@LevinCeglie

@LevinCeglie LevinCeglie commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Includes:

  • chore(cli): removed 'list' from core commands and created aliases for backwards compatibility
  • feat(cli): cleaned up and improved error handling in the CLI
  • fix(backend): increase skip validation upper bound
  • fix(cli): fix potential printing issue due to sorting by incomparable mission/file object
  • feat(cli): add error handling for HTTPStatusError

@LevinCeglie LevinCeglie linked an issue Jun 8, 2026 that may be closed by this pull request
@LevinCeglie
LevinCeglie force-pushed the feat/cli_improvements branch from c31b285 to a5b035a Compare June 9, 2026 11:41
@LevinCeglie LevinCeglie linked an issue Jun 9, 2026 that may be closed by this pull request
@LevinCeglie LevinCeglie changed the title Various CLI improvements and fixes Various CLI improvements and fixes (and one backend fix) Jun 10, 2026
@LevinCeglie
LevinCeglie marked this pull request as ready for review June 15, 2026 09:19
@LevinCeglie
LevinCeglie requested a review from wp99cp June 15, 2026 09:19
@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR consolidates CLI error handling into a central register_error_handlers function with per-exception-type handlers for httpx.RequestError and httpx.HTTPStatusError, removes scattered try/except blocks across command modules, migrates input validation to typer.BadParameter, and moves list sub-commands into the canonical file/mission/project typers (keeping list * as hidden back-compat aliases). It also fixes a TypeError when sorting missions/files that contained incomparable objects, and raises the skip pagination upper bound to Number.MAX_SAFE_INTEGER.

  • Centralized error handling: handle_request_error and handle_http_status_error provide rich, context-aware messages for network and HTTP errors; the handler dispatch order (most-specific registered last, checked first) is correct.
  • Backwards-compatible list commands: the existing klein list files/missions/projects surface is preserved via deferred-import delegation, and new klein file list, klein mission list, klein project list commands are added and covered by both unit and e2e tests.
  • Sorting fix: missions_to_table and files_to_table now use a key-lambda instead of embedding the object in a tuple, correctly avoiding TypeError on incomparable Mission/File objects.

Confidence Score: 5/5

Safe to merge — the structural changes are well-tested and the error-handling refactor is logically correct.

All changed code paths have unit and/or e2e test coverage; the handler dispatch order is verified correct; the sorting fix is straightforward; the only findings are minor debugging-ergonomics nits in the new error handlers that do not affect runtime behavior for regular users.

No files require special attention.

Important Files Changed

Filename Overview
cli/kleinkram/cli/error_handling.py New centralized error handlers with good per-status-code messages; raise exc in debug branches loses original traceback (should be bare raise).
cli/kleinkram/cli/_executions.py Local try/except blocks removed; InvalidMissionQuery re-raised with from e chain; UUID validation now uses typer.BadParameter; looks correct.
cli/kleinkram/printing.py Sorting fix replaces tuple-of-(str, str, Mission) sort with a key-based lambda, correctly avoiding TypeError on incomparable Mission/File objects.
cli/kleinkram/cli/_list.py Backward-compat list {files,missions,projects} commands now delegate to the canonical sub-command implementations via deferred imports; clean approach.
cli/kleinkram/cli/app.py Error handler registration moved to register_error_handlers(app); list typer hidden (kept for back-compat); handler dispatch order is correct.
packages/validation/src/skip-validation.ts Upper bound for skip lifted from 9999 to Number.MAX_SAFE_INTEGER; error message updated accordingly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[CLI command invoked] --> B[ErrorHandledTyper.__call__]
    B --> C{Exception raised?}
    C -- No --> D[Normal exit]
    C -- Yes --> E{ClickException?}
    E -- Yes --> F[re-raise to Click]
    E -- No --> G[iterate handlers in reverse order]
    G --> H{isinstance httpx.HTTPStatusError?}
    H -- Yes --> I[handle_http_status_error\ndisplay status-code-specific message\nlog traceback]
    H -- No --> J{isinstance httpx.RequestError?}
    J -- Yes --> K[handle_request_error\ndisplay connect/timeout/network message\nlog traceback]
    J -- No --> L{isinstance Exception?}
    L -- Yes --> M[handle_generic_exception\ndisplay_error\nlog traceback]
    I --> N{debug mode?}
    K --> N
    M --> N
    N -- Yes --> O[raise exc]
    N -- No --> P[SystemExit 1]
Loading

Reviews (2): Last reviewed commit: "fix(cli+sdk): minor fixes" | Re-trigger Greptile

Comment thread cli/kleinkram/cli/error_handling.py Outdated
Comment thread cli/kleinkram/cli/error_handling.py
Comment thread cli/kleinkram/cli/_executions.py Outdated
@LevinCeglie
LevinCeglie merged commit a432410 into dev Jun 17, 2026
4 of 5 checks passed
@LevinCeglie
LevinCeglie deleted the feat/cli_improvements branch June 17, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant