Skip to content

chore(cli): migrate @fern-api/cli-v2 to use CliError#14992

Draft
FedeZara wants to merge 1 commit intomainfrom
FedeZara/refactor/cli-error-cli-v2
Draft

chore(cli): migrate @fern-api/cli-v2 to use CliError#14992
FedeZara wants to merge 1 commit intomainfrom
FedeZara/refactor/cli-error-cli-v2

Conversation

@FedeZara
Copy link
Copy Markdown
Contributor

@FedeZara FedeZara commented Apr 14, 2026

Description

Migrates @fern-api/cli-v2 (the next-generation CLI package) to use explicit CliError error codes on every failAndThrow / failWithoutThrowing call site.

This is one of the package migration PRs that follow the error classification system introduced in #14749.

Changes Made

Assigned typed error codes across 48+ call sites in packages/cli/cli-v2/src/, covering every command handler and shared utility. Also fixed test files to match the async createTestContext signature and the TaskAbortSignal throw type for validation errors.

Error codes used

Code Usage
CONFIG_ERROR Missing config, invalid flags, API not found, multiple APIs without selection
AUTH_ERROR Authentication failures, keyring unavailability, login/logout/switch errors
NETWORK_ERROR HTTP/API call failures, docs publishing errors
VALIDATION_ERROR Schema validation failures, docs/SDK check violations
PARSE_ERROR Malformed YAML/JSON, invalid workspace definitions
VERSION_ERROR Generator version incompatibility
ENVIRONMENT_ERROR Missing prerequisites, directory resolution failures
INTERNAL_ERROR Unexpected states indicating bugs

Files touched (grouped by area)

  • API commands: api/check/, api/compile/, api/merge/, api/split/, api/utils/loadSpec.ts
  • Auth commands: auth/login/, auth/logout/, auth/switch/, auth/token/, auth/whoami/
  • Docs commands: docs/check/, docs/dev/, docs/preview/, docs/preview/delete/, docs/publish/
  • SDK commands: sdk/add/, sdk/check/, sdk/generate/, sdk/preview/, sdk/update/
  • Other commands: check/, config/migrate/, init/, org/create/, org/list/
  • Context & errors: Context.ts, withContext.ts, TaskContextAdapter.ts, FernYmlEditor.ts, DocsChecker.ts
  • Telemetry: TelemetryClient.ts, LifecycleEvent.ts
  • Error types: Deleted errors/CliError.ts (replaced by shared @fern-api/task-context CliError), updated ValidationError.ts, SourcedValidationError.ts, KeyringUnavailableError.ts
  • Tests: GeneratorPipeline.test.ts, compile.test.ts, TelemetryClient.test.ts, and all test context utilities

Testing

  • Existing tests pass (309/309 in cli-v2, excluding e2e)

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@FedeZara FedeZara changed the title refactor(cli): rename FernCliError to TaskAbortSignal chore(cli): migrate @fern-api/cli-v2 to use CliError Apr 14, 2026
@FedeZara FedeZara force-pushed the FedeZara/refactor/cli-error-cli-v2 branch 2 times, most recently from 2b7abf3 to 351512a Compare April 14, 2026 23:01
@FedeZara FedeZara force-pushed the FedeZara/refactor/cli-error-cli-v2 branch from 351512a to caecd6f Compare April 14, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant