Skip to content

Make @useFinalStateVia validation decorator-order independent for PUT operations#4394

Open
Copilot wants to merge 9 commits intomainfrom
copilot/fix-usefinalstatevia-decorator-order
Open

Make @useFinalStateVia validation decorator-order independent for PUT operations#4394
Copilot wants to merge 9 commits intomainfrom
copilot/fix-usefinalstatevia-decorator-order

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

@useFinalStateVia("original-uri") could incorrectly report invalid-final-state when @put was applied before/after it in a different order. The validator was effectively sensitive to decorator execution order instead of final operation shape.

  • Post-decorator validation for @useFinalStateVia

    • Moved @useFinalStateVia validation into a decorator post-validation callback (onTargetFinish).
    • This evaluates HTTP verb/final-state constraints after all decorators on the target operation are applied, removing order dependency.
  • Regression coverage for the reported ordering bug

    • Added a test for:
      • @put @useFinalStateVia("original-uri") on an LRO operation
    • Asserts no invalid-final-state diagnostic and confirms the override is stored as original-uri.
  • Behavioral impact

    • No rule semantics changed; only validation timing changed to match final decorated operation metadata.
@pollingOperation(bar)
@test @put @useFinalStateVia("original-uri")
op foo(): {};

@microsoft-github-policy-service microsoft-github-policy-service Bot added the lib:azure-core Issues for @azure-tools/typespec-azure-core library label May 7, 2026
Copilot AI changed the title [WIP] Fix @useFinalStateVia decorator to recognize put operations consistently Make @useFinalStateVia validation decorator-order independent for PUT operations May 7, 2026
Copilot AI requested a review from timotheeguerin May 7, 2026 14:39
Comment thread packages/typespec-azure-core/src/decorators/use-final-state-via.ts Outdated
@route("/polling")
@get op bar(): {status: "Succeeded" | "Failed" | "Cancelled"};
`);
assert.strictEqual(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot use expectDiagnostics

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in a6f3eb9: the regression test now uses expectDiagnostics(diagnostics, []).

Copilot AI and others added 4 commits May 7, 2026 18:07
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/d6094bc1-183d-4852-9009-4382ff621a74

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/d6094bc1-183d-4852-9009-4382ff621a74

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/d6094bc1-183d-4852-9009-4382ff621a74

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Comment thread .chronus/changes/copilot-fix-usefinalstatevia-decorator-order-2026-4-7-18-6-39.md Outdated
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/618a3a05-8004-439d-af10-6fde0d07caad

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@timotheeguerin
Copy link
Copy Markdown
Member

@copilot run formatter

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 7, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-azure-core@4394

commit: 1dc3dfa

Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/ad275149-796e-4de5-9507-fb351ef41273

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 7, 2026

@copilot run formatter

Done in 93ef2cc. I ran the formatter and committed the resulting formatting-only update in use-final-state-via.test.ts.

@timotheeguerin timotheeguerin marked this pull request as ready for review May 7, 2026 18:46
@azure-sdk
Copy link
Copy Markdown
Collaborator

All changed packages have been documented.

  • @azure-tools/typespec-azure-core
Show changes

@azure-tools/typespec-azure-core - fix ✏️

Make @useFinalStateVia validation decorator-order independent for PUT operations.

@azure-sdk
Copy link
Copy Markdown
Collaborator

You can try these changes here

🛝 Playground 🌐 Website

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:azure-core Issues for @azure-tools/typespec-azure-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: @useFinalStateVia decorator shouldn't rely on decorator order to figure out if operation is put

3 participants