Azure / Azure/typespec-azure

SubscriptionIdParameter is defined as string resulting in generated ProviderHub controller actions to define it as string

Open
#637 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 22h
Merged PRs (30d)
156

Description

### Clear and concise description of the problem

The ProviderHub template generates the controller actions simply as `{{decl operation}}`. What results in an action like this:

```c#
public async Task BeginEvacuateAsync(string subscriptionId, string resourceGroupName, string buildingName)
```

Notice that parameter `subscriptionId` is defined as a `string`. However, in Azure it's always a Guid. I think it'd be safe to assume and rely on it to be always a `Guid`.

The root cause of this is the definition of a common types parameter `SubscriptionIdParameter`:

https://github.com/Azure/typespec-azure-pr/blob/65444497eab4163997fee25fc49b9359fb9fe8dc/packages/typespec-azure-resource-manager/lib/parameters.tsp#L36-L48

which is defined as `string.`

Proposal: define it as `Azure.Core.uuid` instead. However, this change is likely would have widespread consequence, so it should be analyzed and designed carefully.

### Checklist

- [X] Follow our [Code of Conduct](https://github.com/azure/typespec-azure/blob/main/CODE_OF_CONDUCT.md)
- [X] Check that this issue is about the Azure libraries for typespec. For feature request in the typespec language or core libraries file it in the [TypeSpec repo](https://github.com/Microsoft/TypeSpec/issues/new/choose)
- [X] Read the [docs](https://azure.github.io/typespec-azure/).
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Contributor guide

Open the contributing guide

Research direction

Start with packages/typespec-azure-resource-manager/lib/parameters.tsp at the SubscriptionIdParameter definition and inspect the ProviderHub template's {{decl operation}} expansion. Trace the generated controller actions and analyze the wider consequences of changing the parameter type; done means the design is validated and affected actions consistently use the intended subscription ID type.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, typescript
Domain
backend-api-design, tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.