Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/api/src/services/upload/jsonschema/edge.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
]
}
]
},
"propertyNames": {
"pattern": "^[a-z0-9_-]{1,128}$"
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
},
"endpoint": {
Expand All @@ -38,7 +41,8 @@
"type": "object",
"properties": {
"key": {
"type": "string"
"type": "string",
"pattern": "^[a-z0-9_-]{1,128}$"
},
"operator": {
"type": "string",
Expand Down
5 changes: 4 additions & 1 deletion cmd/api/src/services/upload/jsonschema/node.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
}
]
},
"propertyNames": {
"pattern": "^[a-z0-9_-]{1,128}$"
},
"not": {
"required": [
"objectid"
Expand Down Expand Up @@ -105,4 +108,4 @@
]
}
]
}
}
192 changes: 192 additions & 0 deletions cmd/api/src/services/upload/streamdecoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,66 @@ func nodeSchemaFailureCases() []genericIngestAssertion {
{"nodes[0] validation failed with 1 error(s)", "kind 'tag' uses reserved namespace 'tag'"},
},
},
{
name: "node validation: property keys cannot use uppercase characters",
payload: &testPayload{
Nodes: []testNode{
{
ID: "1234",
Kinds: []string{"test"},
Properties: map[string]any{"TESTKey": "asdf"},
},
},
},
validationErrContains: [][]string{
{"nodes[0] schema validation failed with 1 error(s)", "invalid propertyName 'TESTKey'\n- at '': 'TESTKey' does not match pattern"},
},
},
{
name: "node validation: property keys cannot be empty",
payload: &testPayload{
Nodes: []testNode{
{
ID: "1234",
Kinds: []string{"test"},
Properties: map[string]any{"": "asdf"},
},
},
},
validationErrContains: [][]string{
{"nodes[0] schema validation failed with 1 error(s)", "invalid propertyName ''\n- at '': '' does not match pattern"},
},
},
{
name: "node validation: property keys cannot contain spaces",
payload: &testPayload{
Nodes: []testNode{
{
ID: "1234",
Kinds: []string{"test"},
Properties: map[string]any{"test prop": "asdf"},
},
},
},
validationErrContains: [][]string{
{"nodes[0] schema validation failed with 1 error(s)", "invalid propertyName 'test prop'\n- at '': 'test prop' does not match pattern"},
},
},
{
name: "node validation: property keys cannot be longer than 128 chars",
payload: &testPayload{
Nodes: []testNode{
{
ID: "1234",
Kinds: []string{"test"},
Properties: map[string]any{strings.Repeat("a", 129): "asdf"},
},
},
},
validationErrContains: [][]string{
{"nodes[0] schema validation failed with 1 error(s)", "invalid propertyName 'aaaaaaaaaaa", "aaaaaaaaaaa' does not match pattern"},
},
},
}
}

Expand Down Expand Up @@ -1078,6 +1138,138 @@ func edgeSchemaFailureCases() []genericIngestAssertion {
{"edges[0]", "at '/start/match_by'", "value must be one of 'id', 'name'"},
},
},
{
name: "edge validation: property keys cannot use uppercase characters",
payload: &testPayload{
Edges: []testEdge{
{
Kind: "test",
Start: &edgePiece{Value: "1234"},
End: &edgePiece{Value: "5678"},
Properties: map[string]any{"TESTKey": "asdf"},
},
},
},
validationErrContains: [][]string{
{"edges[0] schema validation failed with 1 error(s)", "invalid propertyName 'TESTKey'\n- at '': 'TESTKey' does not match pattern"},
},
},
{
name: "edge validation: property keys cannot be empty",
payload: &testPayload{
Edges: []testEdge{
{
Kind: "test",
Start: &edgePiece{Value: "1234"},
End: &edgePiece{Value: "5678"},
Properties: map[string]any{"": "asdf"},
},
},
},
validationErrContains: [][]string{
{"edges[0] schema validation failed with 1 error(s)", "invalid propertyName ''\n- at '': '' does not match pattern"},
},
},
{
name: "edge validation: property keys cannot contain spaces",
payload: &testPayload{
Edges: []testEdge{
{
Kind: "test",
Start: &edgePiece{Value: "1234"},
End: &edgePiece{Value: "5678"},
Properties: map[string]any{"test prop": "asdf"},
},
},
},
validationErrContains: [][]string{
{"edges[0] schema validation failed with 1 error(s)", "invalid propertyName 'test prop'\n- at '': 'test prop' does not match pattern"},
},
},
{
name: "edge validation: property keys cannot be longer than 128 chars",
payload: &testPayload{
Edges: []testEdge{
{
Kind: "test",
Start: &edgePiece{Value: "1234"},
End: &edgePiece{Value: "5678"},
Properties: map[string]any{strings.Repeat("a", 129): "asdf"},
},
},
},
validationErrContains: [][]string{
{"edges[0] schema validation failed with 1 error(s)", "invalid propertyName 'aaaaaaaaaaa", "aaaaaaaaaaa' does not match pattern"},
},
},
{
name: "edge validation: property_matchers key values cannot use uppercase characters",
payload: &testPayload{
Edges: []testEdge{
{
Kind: "test",
Start: &edgePiece{Value: "1234"},
End: &edgePiece{MatchBy: "property", PropertyMatchers: []propertyMatcher{
propertyMatcher{Key: "TESTKey", Operator: "equals", Value: "asdf"},
}},
},
},
},
validationErrContains: [][]string{
{"edges[0] schema validation failed with 1 error(s)", "at '/end/property_matchers/0/key': 'TESTKey' does not match pattern"},
},
},
{
name: "edge validation: property_matchers key values cannot be empty",
payload: &testPayload{
Edges: []testEdge{
{
Kind: "test",
Start: &edgePiece{Value: "1234"},
End: &edgePiece{MatchBy: "property", PropertyMatchers: []propertyMatcher{
propertyMatcher{Key: "", Operator: "equals", Value: "asdf"},
}},
},
},
},
validationErrContains: [][]string{
{"edges[0] schema validation failed with 1 error(s)", "at '/end/property_matchers/0/key': '' does not match pattern"},
},
},
{
name: "edge validation: property_matchers key values cannot contain spaces",
payload: &testPayload{
Edges: []testEdge{
{
Kind: "test",
Start: &edgePiece{Value: "1234"},
End: &edgePiece{MatchBy: "property", PropertyMatchers: []propertyMatcher{
propertyMatcher{Key: "test prop", Operator: "equals", Value: "asdf"},
}},
},
},
},
validationErrContains: [][]string{
{"edges[0] schema validation failed with 1 error(s)", "at '/end/property_matchers/0/key': 'test prop' does not match pattern"},
},
},
{
name: "edge validation: property_matchers key values cannot be longer than 128 chars",
payload: &testPayload{
Edges: []testEdge{
{
Kind: "test",
Start: &edgePiece{Value: "1234"},
End: &edgePiece{MatchBy: "property", PropertyMatchers: []propertyMatcher{
propertyMatcher{Key: strings.Repeat("a", 129), Operator: "equals", Value: "asdf"},
}},
},
},
},
validationErrContains: [][]string{
{"edges[0] schema validation failed with 1 error(s)", "at '/end/property_matchers/0/key': 'aaaaaaaaaaa", "aaaaaaaaaaa' does not match pattern"},
},
},
}
}

Expand Down
Loading