feat(gax): add getErrorInfoList to ErrorDetails#4150
feat(gax): add getErrorInfoList to ErrorDetails#4150westarle wants to merge 1 commit intogoogleapis:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new method getErrorInfoList() to the ErrorDetails class, allowing retrieval of all ErrorInfo messages from an error response, which is a useful enhancement. The implementation is clean, and it includes unit tests for the happy path and null input cases. I have one suggestion to improve test coverage by adding a test for the exception handling path.
| Truth.assertThat(errorDetails.getErrorInfoList()) | ||
| .containsExactly(ERROR_INFO, errorInfo2) | ||
| .inOrder(); | ||
| } |
There was a problem hiding this comment.
The new unpackList method can throw a ProtocolBufferParsingException if unpacking fails, which is consistent with the existing unpack method. To ensure complete test coverage for the new logic, please consider adding a test case for this exception scenario, similar to the existing unpack_shouldThrowExceptionIfUnpackingErrorMassageFailed test.
}
@Test
void unpackList_shouldThrowExceptionIfUnpackingErrorMessageFailed() {
Any malformedErrorType =
Any.newBuilder()
.setTypeUrl("type.googleapis.com/google.rpc.ErrorInfo")
.setValue(ByteString.copyFromUtf8("This is an invalid message!"))
.build();
errorDetails =
ErrorDetails.builder().setRawErrorMessages(ImmutableList.of(malformedErrorType)).build();
ProtocolBufferParsingException exception =
assertThrows(
ProtocolBufferParsingException.class, () -> errorDetails.unpackList(ErrorInfo.class));
Truth.assertThat(exception.getMessage())
.isEqualTo(
String.format(
"Failed to unpack %s from raw error messages", ErrorInfo.class.getSimpleName()));
}References
- The repository style guide states that all new logic should be accompanied by tests. The exception handling path in the new
unpackListmethod is currently not covered by tests. (link)
| * This returns all occurrences of ErrorInfo. A single error response may contain multiple | ||
| * ErrorInfo messages. | ||
| */ | ||
| public List<ErrorInfo> getErrorInfoList() { |
There was a problem hiding this comment.
Per aip-193, Each type of detail payload must be included at most once.
I think this is theoretically possible but a violation of AIP.
There was a problem hiding this comment.
thank you, that's extremely helpful!
No description provided.