Skip to content

Commit

Permalink
Valida tag length and set a limit of 1000
Browse files Browse the repository at this point in the history
Start validating tag length, first with a very big limit that would
prevent any problems at the storaged layer.

This value should be reduced to a more sane and practical limit once the
client itself presents message while validating these.
  • Loading branch information
marcospri committed Feb 28, 2024
1 parent 05be632 commit 8e48ae3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion h/schemas/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class AnnotationSchema(JSONSchema):
"required": ["read"],
},
"references": {"type": "array", "items": {"type": "string"}},
"tags": {"type": "array", "items": {"type": "string"}},
"tags": {"type": "array", "items": {"type": "string", "maxLength": 1000}},
"target": {
"type": "array",
"items": {
Expand Down
1 change: 1 addition & 0 deletions tests/unit/h/schemas/annotation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def test_it_does_not_raise_for_full_valid_data(self, pyramid_request, validate):
),
({"references": False}, "references: False is not of type 'array'"),
({"references": [False]}, "references.0: False is not of type 'string'"),
({"tags": ["tag" * 1000]}, f"tags.0: '{'tag' * 1000}' is too long"),
({"tags": False}, "tags: False is not of type 'array'"),
({"tags": [False]}, "tags.0: False is not of type 'string'"),
({"target": False}, "target: False is not of type 'array'"),
Expand Down

0 comments on commit 8e48ae3

Please sign in to comment.