Skip to content

fix(dashnote): drop misleading message maxLength from note schema#84

Merged
thephez merged 2 commits into
mainfrom
dashnote/msg-length-contract-update
May 21, 2026
Merged

fix(dashnote): drop misleading message maxLength from note schema#84
thephez merged 2 commits into
mainfrom
dashnote/msg-length-contract-update

Conversation

@thephez
Copy link
Copy Markdown
Collaborator

@thephez thephez commented May 21, 2026

Summary

  • Removed maxLength: 10000 from the note.message schema. JSON Schema maxLength counts characters, but Dash Platform enforces a per-field byte cap via max_field_value_size (5120 B / 5 KiB) at the network layer — the contract value misrepresented the real limit, and a user could pass schema validation only to be rejected by the state transition.
  • Updated contract.test.ts to assert maxLength is absent.
  • Updated dashnote/CLAUDE.md — schema description and the field-limits gotcha now explain the real cap and why schema maxLength can't honestly mirror it.

The UI already gates message input to 5120 bytes via src/lib/fieldLimits.ts, so user-visible behavior is unchanged.

Notes

  • Not re-registering the contract. DEFAULT_CONTRACT_ID still resolves to the existing on-chain contract (which has the old maxLength: 10000). This is forward-compatible: any contract registered fresh from this code (Settings → Register) will use the cleaner schema, and existing documents on the old contract are unaffected because the network's byte cap was always the binding constraint.
  • title keeps maxLength: 120 — well under 5120 B even in the worst case, so it stays an honest UX-level bound.

Summary by CodeRabbit

  • Documentation

    • Clarified note message field character limits, which are now determined by the network's system-level byte constraint (5 KiB) rather than a fixed character count
  • Updates

    • Reduced note title field maximum character length from 10,000 to 120 characters to align with typical usage patterns

Review Change Stack

The network enforces a 5120-byte per-field cap via max_field_value_size;
JSON Schema maxLength counts characters, so any value here misrepresents
the real limit. UI already gates input to 5120 B.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Warning

Rate limit exceeded

@thephez has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 26 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6b6b305e-7f8c-40c8-9d00-4528268f89a6

📥 Commits

Reviewing files that changed from the base of the PR and between fc39824 and 9a4918e.

📒 Files selected for processing (2)
  • example-apps/dashnote/CLAUDE.md
  • example-apps/dashnote/test/fieldLimits.test.ts
📝 Walkthrough

Walkthrough

This PR updates field validation constraints in the dashnote application. The title field's maximum length is reduced from 10,000 to 120 characters in the schema definition. The message field no longer enforces a schema-level character limit, relying instead on the network's system-level byte limit. Tests and documentation are updated accordingly.

Changes

Field validation constraints

Layer / File(s) Summary
Field constraint definitions and tests
example-apps/dashnote/src/dash/contract.ts, example-apps/dashnote/test/contract.test.ts
The NOTE_SCHEMAS contract tightens title maxLength from 10,000 to 120. Test assertions for message are updated to remove the maxLength expectation and verify position, confirming the field constraint changes.
Constraint documentation
example-apps/dashnote/CLAUDE.md
Documentation is updated to explain that the message field constraint is enforced by the network's system-level max_field_value_size (5120 bytes / 5 KiB) rather than a schema-level character limit.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A note's form takes shape with tighter bounds,
The title trimmed to one-twenty grounds,
The message floats free from schema's chain,
Network limits keep all nice and sane!
Tests dance in place, docs shine so bright,

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and accurately summarizes the main change: removing a misleading maxLength constraint from the message field in the note schema, which is the primary purpose of this changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dashnote/msg-length-contract-update

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 and usage tips.

…moji

Adds boundary cases at 5119/5120/5121 bytes plus 2-byte (é), 3-byte (CJK),
4-byte (emoji), and ZWJ-joined sequences to lock in that the byte gate
catches multi-byte payloads a char-based maxLength would have let through.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thephez thephez merged commit b34ca54 into main May 21, 2026
5 checks passed
@thephez thephez deleted the dashnote/msg-length-contract-update branch May 21, 2026 18:55
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