Skip to content

(janitor/dedupe): share provider-review error classification - #7564

Merged
kilo-code-bot[bot] merged 1 commit into
mainfrom
janitor/dedupe-provider-review-errors
Oct 19, 2026
Merged

kilo-code-bot[bot] merged 1 commit into
mainfrom
janitor/dedupe-provider-review-errors

Conversation

@kilo-code-bot

@kilo-code-bot kilo-code-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Deduplicates the provider-review error classification that was duplicated verbatim across the GitLab and Bitbucket authorization adapters, and consolidates it into the existing owning package @kilocode/app-shared/provider-review (described as the "pure vocabulary" for the PR/MR review layer).

What changed

  • Added packages/app-shared/src/provider-review/errors.ts exporting:
    • ProviderReviewErrorKind — the shared mobile error-state union (not_found | forbidden | stale_head | bad_request | retryable)
    • ProviderReviewError — base classified failure (derives retryable from kind === 'retryable')
    • ProviderApiStatusError — base HTTP-status failure
    • isNetworkFailure — the network-failure probe
  • gitlab-authorization.ts and bitbucket-authorization.ts now extend these shared base classes and import isNetworkFailure, removing the duplicated type/class bodies (kept *ReviewErrorKind as aliases and preserved each provider's name and fixed copy).
  • provider-review-router.ts narrows on a single ProviderReviewError instead of GitLabReviewError || BitbucketReviewError.
  • Added errors.test.ts covering retryable derivation and isNetworkFailure.

Why

The error-kind union is one domain concept (the mobile error-state contract): a new state must be added everywhere at once, and the two copies could drift. This concentrates the vocabulary in the authoritative owner and deletes ~63 lines of duplicated type/class declarations.

Verification

  • pnpm --filter @kilocode/app-shared typecheck — passed
  • pnpm --filter @kilocode/app-shared exec vitest run src/provider-review/errors.test.ts — 5 passed
  • web tsgo --noEmit — passed
  • oxfmt --check and oxlint on changed files — clean

Web Jest suites (gitlab-authorization.test.ts, bitbucket-authorization.test.ts) could not run in this sandbox: their global setup requires PostgreSQL, which is unavailable here.

Consolidate the shared provider-review error vocabulary into
@kilocode/app-shared/provider-review: the ProviderReviewErrorKind union,
the ProviderReviewError and ProviderApiStatusError base classes, and the
isNetworkFailure probe. The GitLab and Bitbucket authorization adapters
now extend the shared base classes instead of duplicating them, and the
router narrows on a single ProviderReviewError type.
@kilo-code-bot kilo-code-bot Bot added the janitor Automated dead-code/duplication cleanup label Oct 15, 2026
@kilo-code-bot
kilo-code-bot Bot enabled auto-merge (squash) October 15, 2026 07:16
@kilo-code-bot

kilo-code-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Behavior-preserving dedup of provider-review error classification into @kilocode/app-shared/provider-review; verified the subclass/instanceof changes and the extracted helpers against every consumer with high confidence.

Files Reviewed (6 files)
  • packages/app-shared/src/provider-review/errors.ts
  • packages/app-shared/src/provider-review/errors.test.ts
  • packages/app-shared/src/provider-review/index.ts
  • apps/web/src/lib/provider-review/gitlab-authorization.ts
  • apps/web/src/lib/provider-review/bitbucket-authorization.ts
  • apps/web/src/routers/provider-review-router.ts

Review Notes

  • The extracted ProviderReviewErrorKind union, retryable derivation, and isNetworkFailure probe are verbatim copies of the removed per-adapter bodies, so classification behavior is unchanged.
  • GitLabReviewError and BitbucketReviewError are strict subclasses of ProviderReviewError, so the broadened checks in provider-review-router.ts:378 and provider-review-router.ts:651 select the same error set as the previous GitLabReviewError || BitbucketReviewError disjunction (the base class is never thrown bare).
  • name is still assigned by each subclass (GitLabReviewError, BitbucketReviewError, GitLabApiStatusError, BitbucketApiStatusError), so existing name-based and instanceof test assertions remain valid.
  • The barrel index.ts addition introduces no name collision with capabilities/contracts, and the @kilocode/app-shared/provider-review export map resolves to the same source module for both the base class and its subclasses, so cross-module instanceof identity holds.
  • No memory-leak patterns (caches, listeners, retained references, timers) are introduced by this change.

Reviewed by deepseek-v4.1-flash · Input: 54.8K · Output: 11.7K · Cached: 430.1K

Review guidance: REVIEW.md from base branch main

@kilo-code-bot

kilo-code-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Meta Janitor: Safety review passed; requesting approval.

@eshurakov eshurakov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Independently reviewed the full six-file diff at 7504a28 against base 0c14020, including pinned source, read/write and branch-listing callers, package exports, tests, CI logs, and existing discussion. No major behavioral/security regression or lost coverage found.

Provider subclass identities and names, fixed-copy classification, retryability, tRPC mappings, and stale-head ledger outcomes are preserved. Isolated in-memory execution of pinned source passed 1,004 status cases, 1,036 classification cases, and 14 router mapping cases. CI logs confirm all seven affected web suites and the five new shared-error tests passed; typecheck, lint, and builds are green.

Validation limitation: full Jest/Vitest suites were not rerun locally; isolated assertions stubbed external tRPC/logging seams and do not replace integration tests. No workspace files changed. Head SHA rechecked immediately before submission.

Files Reviewed (6 files)
  • apps/web/src/lib/provider-review/bitbucket-authorization.ts
  • apps/web/src/lib/provider-review/gitlab-authorization.ts
  • apps/web/src/routers/provider-review-router.ts
  • packages/app-shared/src/provider-review/errors.test.ts
  • packages/app-shared/src/provider-review/errors.ts
  • packages/app-shared/src/provider-review/index.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

janitor Automated dead-code/duplication cleanup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant