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

[Bug]: behavior change to HttpOperationResponse.response.body.type in 0.56.0-dev #3225

Closed
4 tasks done
weidongxu-microsoft opened this issue Apr 24, 2024 · 4 comments
Closed
4 tasks done
Assignees
Labels
bug Something isn't working needs-area

Comments

@weidongxu-microsoft
Copy link
Contributor

weidongxu-microsoft commented Apr 24, 2024

Describe the bug

HttpOperationResponse.responses.body.type changes in 0.56.0-dev, compared to 0.55.0

case in cadl-ranch
https://github.com/Azure/cadl-ranch/blob/main/packages/cadl-ranch-specs/http/type/model/visibility/main.tsp#L50-L51

in 0.55.0, the response.body.type is VisibilityModel model with 5 properties
Screenshot 2024-04-24 134338

in next, it is an anonymous model with only 1 property (the one with "read")
Screenshot 2024-04-24 132813


There is some other cases of difference in response, e.g. empty model
https://github.com/Azure/cadl-ranch/blob/main/packages/cadl-ranch-specs/http/type/model/empty/main.tsp#L35

Also see some diff of response status code changed from 204 to 200.

Reproduction

https://github.com/Azure/cadl-ranch/blob/main/packages/cadl-ranch-specs/http/type/model/visibility/main.tsp#L50-L51

next

{
  '@typespec/compiler': '0.56.0-dev.18',
  '@typespec/http': '0.56.0-dev.10',
  '@typespec/openapi': '0.56.0-dev.3',
  '@typespec/rest': '0.56.0-dev.4',
  '@typespec/versioning': '0.56.0-dev.3',
  '@azure-tools/typespec-client-generator-core': '0.42.0-dev.10',
  '@azure-tools/typespec-azure-core': '0.42.0-dev.5',
  '@azure-tools/typespec-azure-resource-manager': '0.42.0-dev.11',
  '@typespec/eslint-config-typespec': '0.56.0-dev.1',
  '@typespec/library-linter': '0.56.0-dev.3'
}

Checklist

@weidongxu-microsoft weidongxu-microsoft added the bug Something isn't working label Apr 24, 2024
@weidongxu-microsoft
Copy link
Contributor Author

weidongxu-microsoft commented Apr 24, 2024

Chenjie notified me that it may be caused by PR #2945

Would e.g. op getModel(@body input: VisibilityModel): @body VisibilityModel; able to make the case follow the behavior of 0.55 ?
(SDK would at least need to know how to make service write an exact round-trip model, e.g. a SDK API from a PUT REST API should take a Resource in request body and return a Resource in response body, even if there is some difference of e.g. @visibility on a few properties -- which would be handled within the model class, e.g. no setter if readOnly, no getter if no "read")

@timotheeguerin
Copy link
Member

timotheeguerin commented Apr 24, 2024

This has been done by design to make sure request and response body resolution use the exact same logic. Http library was doing some very inconsitent thing that were completely blocking and breaking certain scenarios. The change it that the body property is not exactly the body in both the request and response instead of just being in the request and in the response sometimes being the wrapper model.

Use the same logic you did for request and it will work fine.

@timotheeguerin timotheeguerin added the needs-info Mark an issue that needs reply from the author or it will be closed automatically label Apr 25, 2024
@weidongxu-microsoft
Copy link
Contributor Author

weidongxu-microsoft commented Apr 26, 2024

Thanks Timothee.

I will go update the cadl-ranch to e.g.

@get
op getModel(@body input: VisibilityModel): {
  @body output: VisibilityModel
};

Azure/cadl-ranch#567

However, I may reopen it, if we see behavior changed on real service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-area
Projects
None yet
Development

No branches or pull requests

2 participants