Skip to content

fix(platform-errors): user-friendly message for duplicate DPNS name - #915

Merged
lklimek merged 3 commits into
v1.0-devfrom
codex/dpns-dup-name-error
Jul 21, 2026
Merged

lklimek merged 3 commits into
v1.0-devfrom
codex/dpns-dup-name-error

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

Why this PR exists

  • Problem: Registering a DPNS username that's already taken shows the user a raw Rust Debug-formatted internal error instead of an actionable message.
  • What breaks without it: Try to register a DPNS name someone else already holds. The state-transition broadcast fails with a StateError::DuplicateUniqueIndexError consensus error (code 40105), but TaskError's classifier has no arm for that variant, so it falls through to the generic PlatformRejected catch-all: "The platform rejected this request. Please check your input and try again." — no indication the name is taken, no path to self-resolve. In the field this has surfaced as the literal Rust struct dump reaching the banner (PlatformRejected { source_error: StateTransitionBroadcastError { code: 40105, ... DuplicateUniqueIndexError { ... duplicating_properties: ["normalizedParentDomainName", "normalizedLabel"] } ... } }).

What was done

Added a typed classification arm for ConsensusError::StateError(StateError::DuplicateUniqueIndexError(e)) in TaskError::from<SdkError>'s mapper (src/backend_task/error.rs):

  • TaskError::DpnsUsernameAlreadyTaken — message: "This username is already taken. Please choose a different username and try again."
  • TaskError::PlatformEntryConflict — generic fallback for any other duplicate-unique-index case, so those no longer regress to the old vague message either; message: "This request conflicts with an existing entry. Please use different values and try again."

Both preserve the original Box<SdkError> as a typed #[source], matching the convention used by sibling variants. Detection matches only on the typed duplicating_properties() accessor — no string parsing of error text, per this repo's error-handling conventions.

Post-review follow-up: the shared From<SdkError> boundary is reached by any DuplicateUniqueIndexError, not just DPNS registration — src/backend_task/document.rs funnels the same generic document/document-action task path (wired to the Contracts & Documents UI, over arbitrary caller-supplied contracts) through this exact conversion. Deciding the DPNS-specific message purely from property-name content at that shared boundary meant a non-DPNS contract that happens to define a unique index over identically-named fields would incorrectly get the DPNS-branded message. Fixed by making the shared classifier always return the generic PlatformEntryConflict, and relocating the DPNS-specific rebrand to the one call site that actually knows it's registering a DPNS domain (src/backend_task/identity/register_dpns_name.rs) — applied only to the domain-document put, not the preorder put.

Testing

  • from_sdk_error_duplicate_unique_index_dpns_named_fields_is_generic / ..._other_document_is_actionable / ..._boundary_property_counts_are_generic (src/backend_task/error.rs) — the shared classifier stays generic for every DuplicateUniqueIndexError, including 0/1-property boundary cases.
  • rebrand_dpns_domain_conflict_maps_platform_entry_conflict / ..._passes_through_other_errors (src/backend_task/identity/register_dpns_name.rs) — the relocated rebrand function correctly upgrades a DPNS domain conflict and passes every other error through unchanged.
  • cargo test --all-features from_sdk_error_duplicate_unique_index and rebrand_dpns_domain_conflict — all 5 tests pass by name.
  • cargo clippy --all-features --bin dash-evo-tool -- -D warnings — clean.
  • cargo fmt --all — applied.

Breaking changes

None.

Checklist

  • Tests added/updated
  • cargo fmt --all
  • Scoped cargo clippy clean
  • User-facing docs (not needed — error-message copy only)

Attribution

🤖 Co-authored by Claudius the Magnificent AI Agent

StateError::DuplicateUniqueIndexError previously fell through to the
generic PlatformRejected catch-all ("check your input and try again"),
so registering an already-taken DPNS username surfaced a raw
technical message instead of actionable guidance.

Add a typed mapper arm that detects the DPNS domain unique-index
(normalizedParentDomainName + normalizedLabel) and reports "This
username is already taken"; any other duplicate-unique-index case
gets a generic "conflicts with an existing entry" message instead of
regressing to the old vague fallback.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@lklimek, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 25c0d082-c1d9-4c9f-afc2-113565e2661c

📥 Commits

Reviewing files that changed from the base of the PR and between 5d225f2 and 36ecc38.

📒 Files selected for processing (2)
  • src/backend_task/error.rs
  • src/backend_task/identity/register_dpns_name.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/dpns-dup-name-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

lklimek and others added 2 commits July 21, 2026 11:33
…call site

The shared From<SdkError> boundary was contract-blind and could mislabel
non-DPNS duplicate-index conflicts as "username already taken". The
DPNS-specific message now applies only where the code knows it is
registering a DPNS domain.

Co-Authored-By: OpenAI Codex <[email protected]>
@lklimek
lklimek marked this pull request as ready for review July 21, 2026 12:51
@lklimek

lklimek commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@thepastaclaw

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 48 ahead in queue (commit 36ecc38)
Queue position: 49/49

@lklimek
lklimek enabled auto-merge (squash) July 21, 2026 12:55
@lklimek
lklimek merged commit 9c70437 into v1.0-dev Jul 21, 2026
6 checks passed
@lklimek
lklimek deleted the codex/dpns-dup-name-error branch July 21, 2026 12:59
orchardpaytl pushed a commit to orchardpaytl/orchardpay that referenced this pull request Jul 21, 2026
Brings in: shutdown fix (dashpay#905), duplicate-DPNS-name error message
(dashpay#915), startup banner clearing (dashpay#916), nav pointer cursor + tooltips
and wallet-less masternode indication (dashpay#917), onboarding disconnected-
banner suppression (dashpay#907), masternode dialog/nav/passphrase fixes
(dashpay#913), DAPI auto-refresh during pre-1.0 migration (dashpay#908), "Add
Receiving Address" wiring + its test hardening (dashpay#914, dashpay#920), and a CI
timeout bump (dashpay#912). dashpay#906 (shielded re-enable) was already pulled in
individually last session, so its squashed commit merged as a no-op.

Conflicts (6 files) were rebrand-naming overlaps (dash_evo_tool::  vs
orchardpay::  imports) plus one real merge in left_panel.rs, where
OrchardPay's green-icon tint had to combine with upstream's new nav
tooltip. Also fixed 5 files upstream's auto-merged (non-conflicting)
additions left un-rebranded: a stray DASH_EVO_DATA_DIR_LOCK/env-var
name in a new app.rs test, and dash_evo_tool:: references in three
kittest test files.

Added tooltip strings for OrchardPay's own nav entries (OrchardPay,
DashPay) so the new every_nav_entry_has_a_tooltip test covers them —
upstream's version only knows its own nav items. Fixed the new
nav_label_hover_shows_pointer_cursor kittest test: OrchardPay's nav
rail carries two more always-visible entries than upstream's, pushing
"Settings" below the scrollable list's default-size visible viewport;
scroll it into view first, matching what a real user would do.

Verified: cargo check (both feature modes), cargo clippy --all-features
--all-targets -- -D warnings, cargo fmt --all, cargo test --all-features
--workspace (2066 lib + 257 kittest + doc tests, 0 failed), all clean.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
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