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

Include error ID in the error response for new error format #1454

Merged
merged 4 commits into from
Sep 27, 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 @@ -11,6 +11,7 @@ interface Fields {
String MESSAGE = "message";
// Only included in debug mode, backwards compatible with old style
String EXCEPTION_CLASS = "exceptionClass";
String ID = "id";
}

/** Tags used when tracking metrics */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public CommandResult.Error apply(APIException apiException) {
errorFields.put(ErrorObjectV2Constants.Fields.FAMILY, apiException.family.name());
errorFields.put(ErrorObjectV2Constants.Fields.SCOPE, apiException.scope);
errorFields.put(ErrorObjectV2Constants.Fields.TITLE, apiException.title);
errorFields.put(ErrorObjectV2Constants.Fields.ID, apiException.errorId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java doc to describe what these fields are.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a whole bunch of docs on the ApiException that explains all the fields, your comment has reminded me that it's about time we refactor the CommandResult.Error it is a mess with the map.

if we do this, then we dont need all these fields and maps etc see #1462

}
if (debugEnabled) {
errorFields.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ String getErrorConfigResource() {
public void productionModeCommandResult() {
var exception = TestRequestException.Code.NO_VARIABLES_TEMPLATE.get();
var result = new APIExceptionCommandErrorBuilder(false, true).apply(exception);
assertCommandError(exception, result, 4, true);
assertCommandError(exception, result, 5, true);
}

@Test
Expand All @@ -34,7 +34,7 @@ public void preErrorV2ModeCommandResult() {
public void debugModeCommandResult() {
var exception = TestRequestException.Code.NO_VARIABLES_TEMPLATE.get();
var result = new APIExceptionCommandErrorBuilder(true, true).apply(exception);
assertCommandError(exception, result, 5, true);
assertCommandError(exception, result, 6, true);

assertThat(result)
.isNotNull()
Expand Down Expand Up @@ -88,7 +88,8 @@ private void assertErrorFields(
.as("Error fields - fields new in v2 schema")
.containsEntry(ErrorObjectV2Constants.Fields.FAMILY, exception.family.name())
.containsEntry(ErrorObjectV2Constants.Fields.SCOPE, exception.scope)
.containsEntry(ErrorObjectV2Constants.Fields.TITLE, exception.title);
.containsEntry(ErrorObjectV2Constants.Fields.TITLE, exception.title)
.containsEntry(ErrorObjectV2Constants.Fields.ID, exception.errorId);
}
}
}