Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve message for ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION #1171

Merged
merged 2 commits into from
Jun 17, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public enum ErrorCode {

SHRED_DOC_LIMIT_VIOLATION("Document size limitation violated"),

SHRED_DOC_KEY_NAME_VIOLATION("Document key name constraints violated"),
SHRED_DOC_KEY_NAME_VIOLATION("Document field name invalid"),

SHRED_BAD_EJSON_VALUE("Bad JSON Extension value"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ private void validateObjectKey(String key, JsonNode value, int depth, int parent
;
} else {
throw ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION.toApiException(
"property name ('%s') contains character(s) not allowed", key);
"field name ('%s') contains invalid character(s), can contain only letters (a-z/A-Z), numbers (0-9), underscores (_), and hyphens (-)",
key);
}
}
int totalPathLength = parentPathLength + key.length();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public void catchEmptyPropertyName() {
.isInstanceOf(JsonApiException.class)
.hasFieldOrPropertyWithValue("errorCode", ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION)
.hasMessageStartingWith(ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION.getMessage())
.hasMessageEndingWith("Document key name constraints violated: empty names not allowed");
.hasMessageEndingWith("empty names not allowed");
}

@ParameterizedTest
Expand All @@ -440,9 +440,9 @@ public void catchInvalidPropertyName(String invalidName) {
.hasFieldOrPropertyWithValue("errorCode", ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION)
.hasMessageStartingWith(ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION.getMessage())
.hasMessageEndingWith(
"Document key name constraints violated: property name ('"
"field name ('"
+ invalidName
+ "') contains character(s) not allowed");
+ "') contains invalid character(s), can contain only letters (a-z/A-Z), numbers (0-9), underscores (_), and hyphens (-)");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void badEJSONUnrecognized() {

assertThat(t)
.isNotNull()
.hasMessageStartingWith("Document key name constraints violated")
.hasMessageStartingWith(ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION.getMessage())
.hasFieldOrPropertyWithValue("errorCode", ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,7 @@ public void docUnknownEJsonAsValue() {
assertThat(t)
.isNotNull()
.hasFieldOrPropertyWithValue("errorCode", ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION)
.hasMessageStartingWith(
ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION.getMessage()
+ ": property name ('$unknownType') contains character(s) not allowed");
.hasMessageStartingWith(ErrorCode.SHRED_DOC_KEY_NAME_VIOLATION.getMessage());
}
}

Expand Down