Skip to content

test: fuzz metadata_limits validators with multi-byte UTF-8 sequences (closes #613)#782

Merged
greatest0fallt1me merged 1 commit into
Predictify-org:masterfrom
nuhumusamagaji:test/metadata-limits-fuzz
Jun 29, 2026
Merged

test: fuzz metadata_limits validators with multi-byte UTF-8 sequences (closes #613)#782
greatest0fallt1me merged 1 commit into
Predictify-org:masterfrom
nuhumusamagaji:test/metadata-limits-fuzz

Conversation

@nuhumusamagaji

@nuhumusamagaji nuhumusamagaji commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Closes #613


Summary

Addresses #613 by hardening metadata_limits validators for multi-byte UTF-8 input and adding property-based test coverage.

  • Length policy documented and fixed: All string validators now count Unicode scalar values (.chars()), not UTF-8 byte length (String::len()). A 4-byte glyph like 😀 counts as one character toward the limit.
  • Control-character rejection: Validators reject Unicode control characters (char::is_control()) with Error::InvalidInput.
  • No unwrap() in validators: Vector iteration uses get(i).ok_or(Error::InvalidInput)?.
  • Proptest fuzzers: 8 property tests (256 cases each) for validate_question_length, validate_outcome_length, validate_category_metadata, and validate_tag_metadata, using proptest::string::string_regex for printable ASCII and supplementary-plane symbols.
  • Deterministic edge cases: Empty/at-limit/just-over-limit behavior and explicit 4-byte glyph (U+1F600) tests.

Files changed

File Change
contracts/predictify-hybrid/src/metadata_limits.rs scan_metadata_text helper, scalar-length checks, control-char rejection, removed unwrap()
contracts/predictify-hybrid/src/metadata_limits_tests.rs Unit edge cases + proptest_fuzz module

Length semantics (documented in module rustdoc)

Measure Used? Notes
Unicode scalar values Matches docs ("500 characters") and CreationValidator
UTF-8 byte length Previous behavior; inconsistent with docs
Control characters ❌ rejected Returns InvalidInput

Test plan

Document Unicode scalar length semantics, reject control characters,
and add proptest fuzzers with 4-byte UTF-8 edge-case coverage for
question, outcome, category, and tag metadata validators.
@greatest0fallt1me greatest0fallt1me merged commit cb70322 into Predictify-org:master Jun 29, 2026
1 check failed
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.

Add proptest fuzzers for metadata_limits validators with multi-byte UTF-8 sequences

2 participants