Skip to content

Use HttpResponseException in annotation-processor #45053

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

samvaity
Copy link
Member

Description

Closes #43728

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

Comment on lines +210 to +186
String contentType = response.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE);
if ("application/octet-stream".equalsIgnoreCase(contentType)) {
String contentLength = response.getHeaders().getValue(HttpHeaderName.CONTENT_LENGTH);
exceptionMessage.append("(").append(contentLength).append("-byte body)");
} else if (data == null || data.toBytes().length == 0) {
exceptionMessage.append("(empty body)");
} else {
exceptionMessage.append('"').append(new String(data.toBytes(), StandardCharsets.UTF_8)).append('"');
Copy link
Member Author

Choose a reason for hiding this comment

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

@alzimmermsft I have been considering if we want to port this functionality over from RestProxy, especially where we check the content type and length to determine body length, as well as the exception messages. Should we just let it fall through instead? I think we will still need to check if data is null/empty to avoid decoding it, but for other cases, just let it fall through. Also, do we need custom messaging? It doesn't add much.

Copy link
Member

@alzimmermsft alzimmermsft Apr 25, 2025

Choose a reason for hiding this comment

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

The checks around application/octet-stream were done as there isn't a good string representation as it's expected to just be a stream of bytes, which could be anything. And there's also a chance the body was drained and ignored on the failure, which could result in errors if we tried to read it (as we don't buffer for octet-stream).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Error Handling : annotation-processor
3 participants