Azure / Azure/azure-rest-api-specs

[BUG] Missing @maxLength(25) on ScheduledActionProperties.displayName in models.tsp

Open
#42,206 5 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Cost Management - Query customer-reported Mgmt question Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
6k
Avg merge
2d 21h
Merged PRs (30d)
432

Description

Update:

The product team shared the following comment –

We had to add extra validations in Views and Scheduled actions due to recent phishing attempts on our service. This is a new change we have not yet make doc updates and was done as part of a fraud mitigation effort. For scheduled actions, the change is currently rolling out

API Spec link

https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cost-management/resource-manager/Microsoft.CostManagement/CostManagement/models.tsp

API Spec version

2022-10-01 (also affects all versions through 2025-03-01)

Describe the bug

The displayName property in ScheduledActionProperties (models.tsp) is defined as a plain string with no @maxLength decorator:

model ScheduledActionProperties {
Scheduled action name.
displayName: string;

However, the Azure server enforces a 25-character maximum and returns:
"Scheduled action display name length exceeds the allowed limit of 25 characters. Please shorten the display name."

This constraint is missing from:

Other properties in NotificationProperties mention their limits in descriptions (subject: 70 chars, message: 250 chars) but also lack actual @maxLength decorators.

Microsoft's own documentation example uses "Monthly Cost By Resource" which is exactly 25 characters — barely passing the hidden limit.

Expected behavior

The TypeSpec definition should include the @maxLength(25) decorator on displayName so the constraint is:

  1. Visible in generated documentation
  2. Propagated to generated OpenAPI specs as "maxLength": 25
  3. Enforced at compile time by Bicep, ARM templates, and Terraform
  4. Consistent with actual server-side behavior

Expected fix in models.tsp:

model ScheduledActionProperties {
Scheduled action name. Length is limited to 25 characters.
@maxLength(25)
displayName: string;

Actual behavior
  • displayName is defined as plain "string" with no length constraint in models.tsp
  • The generated scheduledActions.json for all versions (stable/2022-10-01, stable/2023-03-01, stable/2023-08-01, stable/2023-09-01, stable/2023-11-01, stable/2024-08-01, stable/2025-03-01, and all previews) have no maxLength on the displayName property in ScheduledActionProperties
  • The server silently enforces a 25-character limit and rejects longer values with HTTP 400 BadRequest
  • No changelog entry documents when this validation was introduced or enforced
  • Bicep deployments fail at runtime instead of at compile time because the Bicep type system has no maxLength constraint to validate against
  • This is a silent breaking change — deployments that previously succeeded now fail
Reproduction Steps
  1. Create a Bicep file targeting subscription scope:
resource scheduledAction 'Microsoft.CostManagement/scheduledActions@2022-10-01' = {
  name: 'dailyanomalybyresourcegroup'
  kind: 'InsightAlert'
  properties: {
    displayName: 'Daily anomaly by resource group'  // 35 chars - exceeds hidden 25-char limit
    status: 'Enabled'
    viewId: '${subscription().id}/providers/Microsoft.CostManagement/views/ms:DailyAnomalyByResourceGroup'
    notification: {
      subject: 'Daily anomaly by resource group'
      to: ['user@example.com']
    }
    notificationEmail: 'user@example.com'
    schedule: {
      frequency: 'Daily'
      startDate: '2026-04-08T08:00Z'
      endDate: '2030-04-08T08:00Z'
    }
  }
}
  1. Deploy to Azure:

    • Bicep compilation succeeds (no maxLength validation exists)
    • ARM template validation succeeds
  2. ARM deployment FAILS with BadRequest:

    "Scheduled action display name length exceeds the allowed limit of 25 characters. Please shorten the display name."

  3. Changing displayName to 'Daily Anomaly by RG' (19 chars) succeeds.

  4. Verified the same behavior with the REST API directly:

    PUT https://management.azure.com/subscriptions/{subId}/providers/Microsoft.CostManagement/scheduledActions/dailyanomalybyresourcegroup?api-version=2022-10-01
    

    Same BadRequest error.

Environment
  • Deployment method: Azure Bicep via Azure DevOps Pipelines
  • Bicep resource type: Microsoft.CostManagement/scheduledActions@2022-10-01
  • Region: Sweden Central
  • Date first observed: April 8, 2026
  • TypeSpec source file: specification/cost-management/resource-manager/Microsoft.CostManagement/CostManagement/models.tsp
  • Property: ScheduledActionProperties.displayName
  • Affected OpenAPI spec files:
    • stable/2022-10-01/scheduledActions.json
    • stable/2023-03-01/scheduledActions.json
    • stable/2023-08-01/scheduledActions.json
    • stable/2023-09-01/scheduledActions.json
    • stable/2023-11-01/scheduledActions.json
    • stable/2024-08-01/scheduledActions.json
    • stable/2025-03-01/scheduledActions.json (via examples/)
    • preview/2022-06-01-preview/scheduledActions.json
    • preview/2023-04-01-preview/scheduledActions.json
    • preview/2023-07-01-preview/scheduledActions.json
    • preview/2024-10-01-preview/scheduledActions.json

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at specification/cost-management/resource-manager/Microsoft.CostManagement/CostManagement/models.tsp and inspect ScheduledActionProperties.displayName. Add the documented 25-character constraint, then verify that the affected stable and preview scheduledActions.json files expose maxLength 25 and that the public documentation and scheduled actions changelog reflect the limit. Done means the generated specifications match the server validation across the listed API versions.

Written by the indexing model from the issue text.

Assessment

Domain
api, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.