microsoft / microsoft/typespec

[Bug]: Weird behavior for spread model with additional properties

Open
#4,757 3 comments 0 reactions 0 assignees View on GitHub
bug lib:http triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

### Describe the bug

For this [spec](https://cadlplayground.z22.web.core.windows.net/cadl-azure/?c=aW1wb3J0ICJAdHlwZXNwZWMvdmVyc2lvbmluZyI7DQrJIGF6dXJlLXRvb2xzL8gsLcYVY29yZcQsdXNpbmcgVslAyRNIdHRwOw0KDQpAc2VydmljZSh7fSkNCkDHa2VkKMc1cykNCm5hbWVzcGFjZSBUZXN0IHsNCiAgZW51bchZc8YTICBAdXNlRGVwZW5kZW5jeShB5ACMLkNvcmUuyCoudjFfMF9QcmV2aWV3XzIpxjh2MSzECX3kAJEgIEByb3V0ZSgiLyLFH29wIGdldEVtYmVkZGluZ3MgaXMgy1pScGNPcGVyYXRpb248xk%2FnAI4gIC4uLkE7yw1Cxw19xW8gIEPEBz7lAQggIG1vZGVsIEHIPnByb3AxOiBzdHLmATjHQ1JlY29yZDx1bmtub3duxDzpALjGQULMQTLNQc0oQ8woM9AofQ0K&e=%40azure-tools%2Ftypespec-autorest&options=%7B%7D) which is simplified from a service definition [here](https://github.com/Azure/azure-rest-api-specs/blob/016b80ae90f5fabc1e572efabd3ecb1030d444c0/specification/ai/ModelClient/routes.tsp#L26), there is a usage of spread model with additional properties (though i think it should be banned). Also, the http body is composed from both the spread thing and azure core traits thing, then the weird thing happened, the http body parameter type will have a query parameter from the trait, which will not happen is the spread model has no additional properties.
![Image](https://github.com/user-attachments/assets/519ed4d5-ab79-495e-8f48-7147ab457802)
I'm wondering if it is a bug for body resolving. But I think a good solution is not allow to spread model with additional properties.

### Reproduction

Compile with the playground or the spec provided.

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.