Skip to content

fix(dpp): cut long platform value text on a character boundary when displaying it - #5434

Merged
PastaPastaPasta merged 2 commits into
v5.1-devfrom
fix/platform-value-display-char-boundary
Oct 15, 2026
Merged

PastaPastaPasta merged 2 commits into
v5.1-devfrom
fix/platform-value-display-char-boundary

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Value's Display cuts text longer than 20 bytes to its first 20 bytes with split_at(20). When byte 20 falls inside a multi-byte UTF-8 character, split_at panics. Anything that formats a Value can hit it, for example the ValueWrongType messages built from a value in document_type/property/mod.rs.

Split out of #5285.

What was done?

The text is now cut with str::floor_char_boundary(20), the last character boundary at or before byte 20.

Two other byte-limited truncations already did this with a hand-written is_char_boundary loop. They now use floor_char_boundary too, with the same output:

  • bounded_message in rs-drive-abci/src/query/service.rs
  • fit_account_label in rs-platform-encryption/src/account_label.rs

How Has This Been Tested?

  • New unit test should_truncate_long_text_on_a_character_boundary in display.rs. It covers text whose byte 20 is inside é, and ASCII text, whose output is unchanged.
  • cargo test -p platform-value --lib display
  • cargo test -p platform-encryption --lib account_label
  • cargo test -p drive-abci --test query_request_errors should_deliver_bounded_oversized_statuses_over_real_grpc

Breaking Changes

None.

In-place changes to shipped generations

None of the changed functions are versioned, and none of the changes can modify consensus:

  • Value's Display: output is byte-identical for every input that did not panic before. That is all text whose byte 20 is a character boundary, including all ASCII. An input that used to panic aborted the process instead of producing a result to agree on.
  • bounded_message and fit_account_label: floor_char_boundary returns the same index as the loop it replaces, so output is identical for every input. Neither runs during block execution. bounded_message limits the length of gRPC query error messages. fit_account_label is only used by clients (rs-sdk, rs-platform-wallet, rs-sdk-ffi) to prepare a DashPay account label for encryption.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Prevented errors when long text contains multibyte characters near display-length limits.
    • Preserved existing truncation behavior for ASCII text and account labels.

PR Hygiene · fcb8b56

  • Bots — coderabbitai ✓ · thepastaclaw ✓
  • Self-review — posted; again after any push
  • Reviewer requests paused — your 5 review slots are occupied; this PR is excluded from reviewers' queues. Required approvals still count without a slot.
  • Build running
  • Approvals
    • rs-drive-abci (packages/rs-drive-abci/src/query/service.rs) — QuantumExplorer or shumkov
    • files with no dedicated owner (packages/rs-platform-encryption/src/account_label.rs, packages/rs-platform-value/src/display.rs) — QuantumExplorer or shumkov

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

…aying it

`Value`'s `Display` truncated text longer than 20 bytes with `split_at(20)`,
which panics when byte 20 falls inside a multi-byte character. It now cuts at
the last character boundary at or before byte 20.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: dashpay/platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8900b15c-4c24-44aa-be10-79bfd1cc25e5
📥 Commits

Reviewing files that changed from the base of the PR and between 71ec2c0 and fcb8b56.

📒 Files selected for processing: 3
  • packages/rs-drive-abci/src/query/service.rs
  • packages/rs-platform-encryption/src/account_label.rs
  • packages/rs-platform-value/src/display.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Three string truncation paths now use UTF-8 character boundaries: query messages, account labels, and value display. Tests cover multibyte-character truncation and unchanged ASCII truncation.

Changes: UTF-8-Safe Truncation

Layer / File(s) Summary
Apply UTF-8-safe truncation
packages/rs-drive-abci/src/query/service.rs, packages/rs-platform-encryption/src/account_label.rs, packages/rs-platform-value/src/display.rs
The query message and account label helpers use floor character boundaries when truncating. Value display avoids slicing inside a multibyte character. Tests cover multibyte and ASCII text.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: quantumexplorer

Merge Risk: ⚪ Minimal · up to fcb8b

The UTF-8-safe truncation change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: truncating long platform value text at a UTF-8 character boundary during display.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions github-actions Bot added this to the v5.1.0 milestone Oct 15, 2026
@thepastaclaw

thepastaclaw commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit fcb8b56) · triage: low

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Oct 15, 2026
@PastaPastaPasta PastaPastaPasta changed the title fix(platform-value): cut long text on a character boundary when displaying it fix(dpp): cut long platform value text on a character boundary when displaying it Oct 15, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

Verified the complete diff at db55f1f: the bounded backward scan safely selects a UTF-8 character boundary and preserves output for previously non-panicking inputs. The regression test covers the reported multibyte failure and unchanged ASCII truncation; no actionable defects remain after verification. This was a static review only; Rust workspace tests were still running in the supplied CI snapshot.

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.1-sol (effort low) — This is a small, contained UTF-8 truncation fix in Value's Display implementation with focused regression coverage and easily verified correctness.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 99% left, weekly 91% left; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 14% left, 5h 100% left)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort medium); agent phase2-reviewer

Replace the hand-rolled is_char_boundary loops in platform-value Display,
the drive-abci query status bound, and the DashPay account label fit with
str::floor_char_boundary (stable since Rust 1.91). Output is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@PastaPastaPasta

Copy link
Copy Markdown
Member Author

@coderabbitai review


🤖 Posted autonomously by Claude on behalf of pasta.

@coderabbitai

coderabbitai Bot commented Oct 15, 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 thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

Verified the complete diff at fcb8b56: the Value display fix safely truncates UTF-8 while preserving previously successful output, and both accompanying refactors preserve existing behavior. No actionable in-scope findings remain after validating the supplied reviews against the source. Static validation included git diff --check; no builds or tests were run, and the supplied CI snapshot still showed Rust workspace tests and PR Hygiene pending, with no failed checks reported.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.1-sol (effort low) — The diff is a small, contained UTF-8 truncation fix with a focused regression test and two equivalent standard-library refactors, making correctness straightforward to confirm.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 99% left, weekly 91% left; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 14% left, 5h 100% left)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@PastaPastaPasta
PastaPastaPasta marked this pull request as draft October 15, 2026 05:05
@github-actions github-actions Bot removed the waiting-bots Waiting for the review bots to report on this head label Oct 15, 2026
@PastaPastaPasta
PastaPastaPasta marked this pull request as ready for review October 15, 2026 15:26
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

/self-reviewed

@github-actions

Copy link
Copy Markdown
Contributor

Missing human approval. Automatic reviewer requests are paused and this PR is excluded from reviewers' queues. Merge, close, or draft another active PR by this author to free a review slot. Required human review can be satisfied without a slot; once all merge requirements are met, PR Hygiene passes.
Full checklist in the description.

@github-actions github-actions Bot added the too-many-open-prs Beyond the author's 5 open PRs; waits for one to merge before a human is asked. label Oct 15, 2026
@PastaPastaPasta
PastaPastaPasta merged commit a35c2b6 into v5.1-dev Oct 15, 2026
83 of 87 checks passed
@PastaPastaPasta
PastaPastaPasta deleted the fix/platform-value-display-char-boundary branch October 15, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

too-many-open-prs Beyond the author's 5 open PRs; waits for one to merge before a human is asked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants