Skip to content

Implement Spector integration tests for azure/client-generator-core/client-default-value#3835

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/implement-spector-integration-tests
Draft

Implement Spector integration tests for azure/client-generator-core/client-default-value#3835
Copilot wants to merge 4 commits intomainfrom
copilot/implement-spector-integration-tests

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Adds Spector integration test coverage for the @clientDefaultValue decorator scenarios, and fixes an emitter bug discovered in the process.

Emitter fix: header params with clientDefaultValue

Optional header parameters with @clientDefaultValue were wrapped in an options?.param !== undefined guard, which prevented the default from ever being sent when the caller omits the option. Since the paramMap already includes a ?? default fallback, the guard is unnecessary and incorrect.

Before (broken):

headers: {
  ...(options?.customHeader !== undefined
    ? { "custom-header": options?.customHeader ?? "application/json" }
    : {}),
}

After (fixed):

headers: {
  "custom-header": options?.customHeader ?? "application/json",
}

The fix is in buildHeaderParameter() in operationHelpers.ts: skip the undefined conditional when the parameter has a type-matching clientDefaultValue. This mirrors how query/path parameters with defaults are already handled.

New test coverage

  • Added azure/client-generator-core/client-default-value to azureModularTsps in cadl-ranch-list.js
  • Generated client and scaffolding (tspconfig.yaml, .gitignore, src/index.d.ts)
  • Created azureClientGeneratorCoreClientDefaultValue.spec.ts covering all four scenarios:
    • putModelProperty — model property defaults (timeout, tier, retry) returned by server
    • getOperationParameter — query param defaults (pageSize=10, format=json) auto-applied
    • getPathParameter — path parameter with explicit default value
    • getHeaderParameter — header defaults (accept, x-custom-header) auto-applied without caller input
  • Updated clientDefaultValue.md unit test snapshot to match corrected header emission
  • Updated @typespec/http-specs and @azure-tools/azure-http-specs to latest dev versions

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits March 10, 2026 08:17
…lient-default-value

Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
…fined check

Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Spector integration tests for client default value Implement Spector integration tests for azure/client-generator-core/client-default-value Mar 10, 2026
@v-jiaodi v-jiaodi added the Experiement Experiement PR/issue for AI label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Experiement Experiement PR/issue for AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants