Skip to content

fix(cli): return a typed 422 for commit-message with no changes - #12033

Merged
marius-kilocode merged 1 commit into
mainfrom
fix-commit-message-no-changes-error
Jul 8, 2026
Merged

fix(cli): return a typed 422 for commit-message with no changes#12033
marius-kilocode merged 1 commit into
mainfrom
fix-commit-message-no-changes-error

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

When generating a commit message with nothing to commit (nothing staged, or only lock files which are filtered out), the user saw a generic Unexpected server error. Check server logs for details. (HTTP 500) instead of a clear, actionable message.

Why

generate.ts throws a plain Error("No changes found to generate a commit message for"). The HTTP handler wraps it via EffectBridge.fromPromise, but Effect maps unhandled promise rejections to Dies, so the plain error becomes an untyped defect. The error middleware treats untyped defects as 500 and masks the message, leaving the user with no idea why generation failed.

The correct pattern for this API surface is to declare an explicit Schema.ErrorClass on the endpoint and fail with that typed error so it surfaces as a real HTTP status with the actual message.

What changed

  • Declare CommitMessageNoChangesError (Schema.ErrorClass, httpApiStatus: 422, { message }) on the commit-message endpoint error contract alongside the existing HttpApiError.BadRequest.
  • Replace the plain Error in generate.ts with a recognizable NoChangesError domain class, so the handler can distinguish it from unexpected defects.
  • In the handler, keep EffectBridge.fromPromise (preserves Kilo instance/workspace contexts across the callback) and add Effect.catchDefect to translate the NoChangesError defect into the typed CommitMessageNoChangesError failure (422). Unexpected defects are re-died so they still surface as masked 500s, which is correct for truly unexpected errors.
  • The VS Code extension shows the real message directly instead of prepending a redundant Failed to generate commit message: prefix that doubled up the wording.
  • Regenerated the SDK so CommitMessageNoChangesError and the 422 status are part of the typed client contract.

All changes are in Kilo-owned paths (packages/opencode/src/kilocode/, packages/kilo-vscode/); no shared upstream files were touched.

A plain Error thrown when no changes are found became an untyped
defect through EffectBridge.fromPromise, which the error middleware
masked as a generic 500 "Unexpected server error". Declare a
CommitMessageNoChangesError (Schema.ErrorClass, httpApiStatus 422)
on the endpoint and translate the domain NoChangesError defect into
that typed failure, so the real message surfaces. The extension now
shows it directly instead of prepending a redundant prefix.
@kilo-code-bot

kilo-code-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilocode/server/httpapi/handlers/commit-message.ts 26 Expected "no changes" failure is modeled as a defect and caught with Effect.catchDefect, which specs/effect/errors.md explicitly says not to do for expected failures
Files Reviewed (9 files)
  • .changeset/commit-message-no-changes-error.md
  • packages/kilo-vscode/src/services/commit-message/index.ts
  • packages/opencode/src/kilocode/commit-message/generate.ts
  • packages/opencode/src/kilocode/commit-message/index.ts
  • packages/opencode/src/kilocode/server/httpapi/groups/commit-message.ts - 0 issues
  • packages/opencode/src/kilocode/server/httpapi/handlers/commit-message.ts - 1 issue
  • packages/opencode/test/kilocode/commit-message/generate.test.ts
  • packages/opencode/test/kilocode/server/commit-message-no-changes.test.ts
  • packages/opencode/test/kilocode/server/httpapi-exercise-scenarios.ts

Note: packages/sdk/js/src/v2/gen/types.gen.ts is a generated SDK file; its unrelated sandbox_writable_paths addition is SDK regen drift, not reviewed per repo policy.

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5-20260630 · Input: 44 · Output: 14.1K · Cached: 1.7M

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 9fc1a1d into main Jul 8, 2026
28 checks passed
@marius-kilocode
marius-kilocode deleted the fix-commit-message-no-changes-error branch July 8, 2026 10:08
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…-Org#12033)

A plain Error thrown when no changes are found became an untyped
defect through EffectBridge.fromPromise, which the error middleware
masked as a generic 500 "Unexpected server error". Declare a
CommitMessageNoChangesError (Schema.ErrorClass, httpApiStatus 422)
on the endpoint and translate the domain NoChangesError defect into
that typed failure, so the real message surfaces. The extension now
shows it directly instead of prepending a redundant prefix.
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.

3 participants