Skip to content

feat(sdk): return typed merge errors - #59

Open
necolas wants to merge 1 commit into
devfrom
necolas/sdk-merge-typed-errors
Open

feat(sdk): return typed merge errors#59
necolas wants to merge 1 commit into
devfrom
necolas/sdk-merge-typed-errors

Conversation

@necolas

@necolas necolas commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Why

Callers must distinguish merge conflicts, stale target guards, and stale source guards without parsing human error text. The current SDKs return ApiError or APIError for every merge failure, even when the server provides a stable 409 code and structured recovery data.

Before this change, the new regression tests failed because all three SDKs returned their generic API error for merge_conflict and precondition_failed responses.

This PR wraps the contracts from monorepo PR #2392 and monorepo PR #2395. The required SDK foundation from SDK PR #51 is now part of dev.

Scope

  • Map merge_conflict 409 responses to RefUpdateError with reason conflict, conflict paths, and the merge base.
  • Map target and source precondition_failed 409 responses to RefUpdateError with the guard plus expected and actual SHAs.
  • Expose language-native field names in TypeScript, Python, and Go.
  • Keep unknown 409 codes and every non-409 merge failure as the existing API error type.
  • Add regression coverage that proves messages do not control classification.
  • Update the three SDK READMEs, the code-storage skill, and release notes.

The separate SDK source-guard task will add the expectedSourceSha, expected_source_sha, and ExpectedSourceSHA request options.

Tradeoffs

Known merge 409 responses now use RefUpdateError instead of the generic API error type. This is the intended behavior change and must not ship as a patch.

Blast Radius

Callers that catch the generic API error for a known merge 409 must migrate to RefUpdateError. Unknown codes and other HTTP statuses keep their current behavior.

The new fields extend Go's exported RefUpdateError struct. External unkeyed struct literals can require an update. Keyed literals and normal returned-error handling remain compatible.

Verification

  • TypeScript: pnpm exec vitest --run passes 277 tests.
  • TypeScript: pnpm build builds ESM, CommonJS, and declarations.
  • Python: ./venv/bin/ruff check pierre_storage tests passes.
  • Python: ./venv/bin/mypy pierre_storage passes with no issues.
  • Python: ./venv/bin/pytest -q passes 211 tests. It reports 65 existing deprecation warnings.
  • Go: go test ./... passes.
  • git diff --check passes.

@necolas
necolas force-pushed the necolas/preview-merge-ephemeral-sdk branch from d578dd4 to 863d00d Compare September 8, 2026 18:34
@notion-workspace

Copy link
Copy Markdown

Base automatically changed from necolas/preview-merge-ephemeral-sdk to dev September 8, 2026 18:37
Map stable merge conflict and guard 409 codes to RefUpdateError in
TypeScript, Python, and Go. Expose conflict and guard details with
language-native field names.

Keep unknown 409 codes and non-409 failures as API errors. Document the
behavior change and coordinated non-patch release.
@necolas
necolas force-pushed the necolas/sdk-merge-typed-errors branch from 9fb43cf to ed00d70 Compare September 8, 2026 18:44
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.

1 participant