Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 17, 2026

Plan to Add exportArray LRO Test with Array Response

  • Understand the existing code structure
    • Review lro.tsp file and existing export operation
    • Review mockapi.ts and understand mock implementation pattern
    • Review ArmProviderActionAsync template definition
    • Understand SubscriptionActionScope usage
  • Add exportArray operation to lro.tsp
    • Create response as direct array type (ExportResult[])
    • Add exportArray operation using ArmProviderActionAsync template with SubscriptionActionScope
    • Add scenario documentation with expected requests/responses
  • Add mock API implementation for exportArray in mockapi.ts
    • Add initial POST request handler at subscription scope
    • Add Location header polling handler
    • Add Azure-AsyncOperation header polling handler
    • Return array response directly (not wrapped)
  • Fix LRO headers based on feedback
    • Add retry-after: 1 header to all 202 responses (including Location polling)
    • Add location header to all Location polling responses
    • Add retry-after and azure-asyncoperation headers to AAO polling when InProgress
    • Add location header to AAO polling when Succeeded
    • Add changeset for the feature
  • Fix response model structure
    • Remove ExportResultArray wrapper model
    • Use ExportResult[] as direct array response type
    • Update mockapi to return array of ExportResult objects
    • Update scenario documentation to reflect array response
  • Format code with prettier
  • Regenerate documentation

Implementation Complete

Successfully added exportArray operation that returns an array of ExportResult objects directly, with proper LRO polling headers that conform to Azure LRO specifications.

Original prompt

This section details on the original issue you should resolve

<issue_title>azure-http-specs, add a test of LRO return has Response/FinalResult as an array</issue_title>
<issue_description>Add a test in packages/azure-http-specs/specs/azure/resource-manager/operation-templates/lro.tsp

Add operation exportArray with template ArmProviderActionAsync, with SubscriptionActionScope
https://github.com/Azure/typespec-azure/blob/main/packages/typespec-azure-resource-manager/lib/operations.tsp#L763-L788

You can refer to the export operation (as well as the corresponding code in "mockapi.ts"), to learn how the operation and mockapi be written, but mind that this uses a slightly different template, so the route is not same.

Have its Response be an array.

Add the mock to existing mockapi.ts</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test for LRO return with Response as array Add LRO test with array response using ArmProviderActionAsync Jan 17, 2026
@weidongxu-microsoft
Copy link
Member

@copilot

In mockapi.ts

For response with status 202, add a

            "retry-after": 1,

header.


In section of "// LRO POST poll intermediate/get final result - Azure-AsyncOperation Header"
When exportArrayPollCount=0, response should also have this retry-after header, as well as the

"azure-asyncoperation": dyn`${dynItem("baseUrl")}/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_exportarray_aao`,

header.

When exportArrayPollCount>0, response should have the location header

location: dyn`${dynItem("baseUrl")}/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_exportarray_location`,

In section of "// LRO POST poll intermediate/get final result - Location Header"
response should always have the location header

location: dyn`${dynItem("baseUrl")}/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_exportarray_location`,

Check the instruction, run the necessary pnpm command, include change add and format

…polling state

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 17, 2026

@copilot

In mockapi.ts
...

All requested changes have been implemented in commit bbdddc2:

  1. ✅ Added retry-after: 1 header to all 202 responses
  2. ✅ Azure-AsyncOperation polling now includes:
    • retry-after and azure-asyncoperation headers when status is InProgress (exportArrayPollCount=0)
    • location header when status is Succeeded (exportArrayPollCount>0)
  3. ✅ Location polling now always includes the location header in responses
  4. ✅ Added changeset using pnpm change add with type "Feature"

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
@weidongxu-microsoft
Copy link
Member

@copilot

The model on the Response is wrong. It should not be a model ExportResultArray with value of string[]. It should be the array itself, e.g. ExportResult[]

Fix this, update mockapi, scenario doc, summary accordingly.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 17, 2026

Open in StackBlitz

npm i https://pkg.pr.new/Azure/typespec-azure/@azure-tools/azure-http-specs@3791

commit: 196c70c

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 17, 2026

@copilot

The model on the Response is wrong. It should not be a model ExportResultArray with value of string[]. It should be the array itself, e.g. ExportResult[]
...

Fixed in commit 02f1d75:

  1. ✅ Removed ExportResultArray wrapper model
  2. ✅ Changed response type to ExportResult[] (direct array)
  3. ✅ Updated mockapi to return array of ExportResult objects: [{content: "..."}, {content: "..."}]
  4. ✅ Updated scenario documentation to show array response format

@weidongxu-microsoft
Copy link
Member

@copilot

run pnpm format

@weidongxu-microsoft
Copy link
Member

@copilot

And pnpm regen-docs

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 17, 2026

@copilot

run pnpm format

Formatted in commit accb6e2.

@weidongxu-microsoft
Copy link
Member

@copilot

run pnpm regen-docs

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 17, 2026

@copilot

And pnpm regen-docs

Documentation regenerated in commit 196c70c.

Copy link
Contributor Author

Copilot AI commented Jan 17, 2026

@copilot

run pnpm regen-docs

Already completed in commit 196c70c. Running pnpm regen-docs again shows no changes needed - documentation is up to date.

@weidongxu-microsoft weidongxu-microsoft added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit 43797ca Jan 20, 2026
23 checks passed
@weidongxu-microsoft weidongxu-microsoft deleted the copilot/add-lro-response-array-test branch January 20, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azure-http-specs, add a test of LRO return has Response/FinalResult as an array

3 participants