Skip to content

fix(dpp): keyword max count mismatch between schema validation (20) and update validation (50) #3420

Description

@thephez

Description

There is a mismatch between the maximum keyword count enforced during contract creation vs contract update.

Creation (schema validation)

packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json line 589:

"description": "List of up to 20 descriptive keywords for the contract, used in the Keyword Search contract"

The schema enforces maxItems: 20 (implicitly via description — should verify exact constraint).

Update (Rust validation)

packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs lines 271-276:

if new_data_contract.keywords().len() > 50 {
    return Ok(SimpleConsensusValidationResult::new_with_error(
        TooManyKeywordsError::new(self.id(), new_data_contract.keywords().len() as u8).into(),
    ));
}

Struct documentation

packages/rs-dpp/src/data_contract/v1/data_contract.rs line 66-67:

This vector can be left empty, but if populated, it must contain unique keywords.
The maximum number of keywords is limited to 20.

Impact

A contract that was created with ≤20 keywords can be updated to have 21–50 keywords, bypassing the intended creation constraint. This is likely unintentional since the doc comment and schema both say 20.

Suggested fix

Align the Rust update validation to use 20 instead of 50 (or update the schema and docs to 50 if the higher limit is intentional).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions