Skip to content

fix: report project-identity bind conflicts accurately instead of always advising adopt/fork - #332

Merged
geekgonecrazy merged 1 commit into
devfrom
fix/329-identity-conflict-reporting
Nov 11, 2026
Merged

geekgonecrazy merged 1 commit into
devfrom
fix/329-identity-conflict-reporting

Conversation

@geekgonecrazy

Copy link
Copy Markdown
Contributor

Root cause

atomic push calls bind_before_push() before any objects move, which POSTs the local project-identity document to <remote>?project-identity=1. On HTTP 409 the client transport:

  1. Dropped the 409 response body — the server's {"code":"IDENTITY_CONFLICT","message":…} was never read, so the operator never saw the real reason.
  2. Conflated the follow-up GET ?project-identity=1 into Option<Value> — None silently merged three very different situations: server reports unbound, fetch failed, and unparsable document.
  3. bind_before_push then rendered remote_id = <unreadable> and always advised atomic repo identity adopt / atomic repo identity fork — advice that cannot work when the remote is actually unbound. This is exactly what an external user hit: a server-side ref-scoping bug made the bind 409 against a sibling project while the follow-up GET reported bound:false (server fix in atomic-storage#113).

The fix (three parts)

1. atomic-remote/src/http/identity.rs

  • New BindServerError { code, message } (both optional, serializable); the 409 body is parsed on the wire — non-JSON bodies tolerated, nested {"error":{…}} spelling accepted as fallback.
  • BindOutcome::Conflict now carries remote: ConflictRemote — an explicit enum { Bound(Value), Unbound, Unknown } — instead of Option<Value>. IdentityFetch::Bound → Bound, IdentityFetch::Unbound → Unbound, any fetch error → Unknown (a pre-transport ping also maps to Unknown, since the binding is unreadable).

2. libatomic/src/identity_transport.rs

  • The conflict message is now built by a pure, unit-testable format_bind_conflict() with per-outcome advice:
    • Bound + different projectId → genuine divergence: both ids rendered, existing adopt/fork advice kept.
    • Bound + same projectId but different document (re-minted) → suggests adopt only; fork would mint a third lineage that conflicts the same way (verified against fork_identity()).
    • Unbound → names the server-side ref-scoping bug (fixed in atomic-storage#113) and advises upgrading the storage server and retrying; no adopt/fork advice.
    • Unknown → states the remote binding could not be read; no remediation triad.
    • Every branch quotes the server's code/message verbatim when present. <unreadable> is gone: a bound document lacking a readable atomic:projectId is explained as such.

3. Tests

  • Wire tests (atomic-remote/tests/project_identity_transport.rs) against the canned HTTP server: 409 with a JSON error body surfaces code+message; 409 + bound:false → ConflictRemote::Unbound; 409 + bound:true → ConflictRemote::Bound(doc); 409 + failing GET → ConflictRemote::Unknown.
  • Inline unit tests in libatomic/src/identity_transport.rs covering every format_bind_conflict branch: divergence keeps adopt/fork, same-project keeps adopt only, unbound has no adopt/fork text and names ci: add dispatchable Prepare Release workflow #113, unknown has no remediation, server words quoted verbatim.

Test evidence

cargo test -p atomic-remote -p libatomic
  atomic-remote:  221 unit + 9 wire tests passed (4 new wire tests)
  libatomic:      40 unit tests passed (5 new format_bind_conflict tests)
                  + all integration suites passed
cargo clippy -p atomic-remote -p libatomic --all-targets   # 0 warnings
cargo fmt --check                                          # clean

Fixes #329 (client half; server half in atomic-storage#113)

…ays advising adopt/fork

The push-time identity bind dropped the server's 409 body on the floor
and collapsed the follow-up binding read into Option<Value>: 'None'
conflated 'server reports unbound' with 'read failed', and the message
always advised 'repo identity adopt'/'fork' — advice that cannot work
when the remote is actually unbound (the storage-side ref-scoping bug
fixed in atomic-storage#113).

- atomic-remote: parse the 409 body into BindServerError {code, message}
  (both optional, non-JSON tolerated, nested error{} accepted) and map
  the follow-up read to an explicit ConflictRemote::{Bound, Unbound,
  Unknown} instead of Option<Value>.
- libatomic: format_bind_conflict renders per-outcome advice — genuine
  divergence keeps adopt/fork, a re-minted document of the same project
  advises adopt only (fork would conflict the same way), an unbound
  report names the storage bug and says upgrade-and-retry, and an
  unknown binding states it could not be read without remediation. The
  server's code/message are quoted verbatim whenever present.

Fixes #329
@geekgonecrazy
geekgonecrazy marked this pull request as ready for review November 11, 2026 19:18
@geekgonecrazy
geekgonecrazy merged commit 8053c02 into dev Nov 11, 2026
10 checks passed
@geekgonecrazy
geekgonecrazy deleted the fix/329-identity-conflict-reporting branch November 11, 2026 19:18
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.

push to a new project fails with "remote project identity is <unreadable>": server 409 IDENTITY_CONFLICT against a sibling project's identity

1 participant