Skip to content

fix(dpp): preserve wasm class mismatch diagnostics - #5428

Merged
shumkov merged 1 commit into
v5.0-devfrom
shumkov/wasm-dpp2-class-diagnostics-20261014
Oct 14, 2026
Merged

shumkov merged 1 commit into
v5.0-devfrom
shumkov/wasm-dpp2-class-diagnostics-20261014

Conversation

@shumkov

@shumkov shumkov commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Basic explanation

What this does: Restore the established expected/actual class diagnostic when a caller supplies an invalid WASM class argument.

Value: SDK callers keep informative validation errors, and seven existing action-fee regression cases pass again.

Risks: Low: only wrong-class diagnostic text changes. Class, module, prototype and pointer rejection conditions keep their ordering; consensus behavior is unaffected.

Issue being fixed or feature implemented

The common instance guard introduced in #5405 correctly refused invalid actionFeeAgreement values but replaced their established diagnostic, causing seven existing SDK tests to fail. This follow-up restores those messages.

What was done?

In wasm_ptr_of_js_val, read the constructor's static __struct once and use the existing class-mismatch formatter when it is absent or different. The subsequent module/prototype checks still run before instance getters and pointer access. Assertions are unchanged.

How Has This Been Tested?

  • Existing action-fee regressions: public tests 7 failing → 9 passing; private wasm32 tests 1 failing → 3 passing.
  • Fresh optimized WASM bindings in Node 24: 671 SDK unit cases and 7 safety controls pass, with zero fetches; protected foreign wrappers have zero instance/pointer reads.
  • Private wasm32 common-conversion and query tests: 5 + 11 cases pass.
  • Scoped native DPP and wasm32 SDK/DPP library Clippy with -D warnings, explicit Rust formatting and whitespace checks pass.

Compressed/browser packaging is left to resulting-head CI. No new or modified test assertions are needed: the existing tests reproduce the regression.

Breaking Changes

None.

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

Summary by CodeRabbit

  • Bug Fixes
    • Invalid instances now report a specific error when their declared class does not match the expected class. Other invalid-instance checks retain their existing behavior.

PR Hygiene · b85ff37

  • Bots — coderabbitai ✓ · thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Build running
  • Approvals — you own every area touched; none needed

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.

Existing action-fee tests caught the regression in CI: ✖ before fix (7 public and 1 private failures), ✔ after fix (9 public and 3 private passes). Restore expected/provided errors from static class metadata before the existing module, prototype and pointer checks.
@shumkov shumkov added this to the v5.0.0 milestone Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 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: 605bbedb-0096-4a79-8bee-260620113c5c
📥 Commits

Reviewing files that changed from the base of the PR and between 2fda500 and b85ff37.

📒 Files selected for processing: 1
  • packages/wasm-dpp2/src/utils.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

wasm_ptr_of_js_val now reports a constructor-name mismatch when __struct differs from the expected class name. Non-function constructors and module-brand failures still return the generic invalid-instance error.

Changes: Instance validation

Layer / File(s) Summary
Constructor validation
packages/wasm-dpp2/src/utils.rs
wasm_ptr_of_js_val now returns a specific error when __struct does not match the expected class name. Non-function constructors and module-brand failures return the generic invalid-instance error.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: quantumexplorer

Merge Risk: ⚪ Minimal · up to b85ff

The change restores class-mismatch diagnostics, and the inspected wrappers provide matching metadata. No actionable merge risk remains.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preserving WASM class mismatch diagnostics in DPP.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
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.
✨ Finishing Touches
📝 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.

@shumkov
shumkov requested a review from thepastaclaw October 14, 2026 09:18
@thepastaclaw

thepastaclaw commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit b85ff37)

@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

The change correctly restores class-mismatch diagnostics without altering validation order or accepted/rejected inputs. One diagnostic path reports an empty provided class for ordinary objects, and the newly duplicated formatter creates minor maintenance drift; neither issue affects safety or consensus behavior.

🟡 1 suggestion(s) | 💬 1 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: ffi-engineer); reviewer 6: 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, well-contained WASM validation change that only restores diagnostic formatting while preserving the existing rejection order and behavior, with no consensus-critical or funds-related impact.
  • 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 94% 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 — ffi-engineer (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 each finding against the current code and only fix it if needed.

In `packages/wasm-dpp2/src/utils.rs`:
- [SUGGESTION] packages/wasm-dpp2/src/utils.rs:164-170: Class-mismatch diagnostics omit the actual constructor name when metadata is absent
  When the supplied value is a plain object, its constructor is typically `Object` and has no `__struct` property. The new fallback therefore formats the error as `Expected DocumentActionFeeAgreement, provided .`, omitting the actual constructor name. This does not change validation, but it falls short of the established diagnostic that this PR is restoring; use the already-validated constructor's `name` property as the fallback when `__struct` is absent.
- [NITPICK] packages/wasm-dpp2/src/utils.rs:166-170: Class-mismatch formatting is duplicated in the same function
  The same error format string now appears in both the new static `__struct` mismatch branch and the existing instance `__type` mismatch branch. Extracting a small local `class_mismatch` formatter would keep these closely related diagnostics synchronized if the wording or fallback behavior changes again.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Legacy wasm-dpp conversion still dereferences freed or unvalidated pointers — The legacy packages/wasm-dpp/src/utils.rs conversion path remains outside this PR and still reads __wbg_ptr after only checking the prototype constructor name. It has no module-brand, prototype-membership, or zero-pointer validation, so a freed object can reach ref_from_abi(0). Track this separately rather than expanding the current diagnostic-only fix.
    • Follow-up: Create a separate issue to harden or deprecate the legacy wasm-dpp conversion path.

Comment thread packages/wasm-dpp2/src/utils.rs Resolved
Comment thread packages/wasm-dpp2/src/utils.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-self-review Waiting for the author to post /self-reviewed label Oct 14, 2026
@shumkov
shumkov merged commit bcbf05c into v5.0-dev Oct 14, 2026
23 of 25 checks passed
@shumkov
shumkov deleted the shumkov/wasm-dpp2-class-diagnostics-20261014 branch October 14, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-self-review Waiting for the author to post /self-reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants