Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 31, 2025

Context:

Summary:

Adds @nullFinalStateVia decorator to force LRO operations to have finalStateVia set to undefined, supporting backward compatibility for language clients that require this specific behavior.

Changes

  • Decorator definition (lib/legacy.tsp): Added @nullFinalStateVia(target: Operation, scope?: valueof string) with scope support
  • Type system (generated-defs/, src/decorators.ts, src/tsp-index.ts): Added NullFinalStateViaDecorator type and $nullFinalStateVia handler
  • Helper function (src/decorators.ts): Exported getNullFinalStateVia(context, operation): boolean for language emitters
  • Interface update (src/interfaces.ts): Changed SdkLroServiceMetadata.finalStateVia from required to optional
  • Logic (src/methods.ts): Modified getServiceMethodLroMetadata() to return undefined for finalStateVia when decorator is applied
  • Tests (test/decorators/null-final-state-via.test.ts): Added coverage for scoping, negation, and interaction with @markAsLro and @finalStateVia

Usage

// Apply to all emitters
@Azure.ClientGenerator.Core.Legacy.nullFinalStateVia
@Azure.Core.lroPollLocation
op startJob(@path jobId: string): JobResult;

// Language-specific
@Azure.ClientGenerator.Core.Legacy.nullFinalStateVia("python")
@Azure.Core.lroPollLocation
op processData(): ProcessingResponse;

Language emitters check via getNullFinalStateVia(context, operation) or test metadata.finalStateVia === undefined.

Original prompt

This section details on the original issue you should resolve

<issue_title>[TCGC] add a legacy decorator @nullFinalStateVia</issue_title>
<issue_description>Goal:

add a legacy decorator @nullFinalStateVia to backward compatibility for some language clients

Ask:
(1) this decorator shall be put in /workspaces/typespec-azure/packages/typespec-client-generator-core/lib/legacy.tsp
(2) this decorator shall pertmit "scope"
(3) add helper function for a method so that language emitter could judge the method is decorated by this decorator
(4)

shall be changed to optional
(5) finalStateValue shall be undefined if a lro method is decorated by it
(6) DO add test case
(7) DO add changelog in .chronus/changes

</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: msyyc <70930885+msyyc@users.noreply.github.com>
Copilot AI changed the title [WIP] Add legacy decorator @nullFinalStateVia for backward compatibility Add @nullFinalStateVia legacy decorator for LRO backward compatibility Dec 31, 2025
Copilot AI requested a review from msyyc December 31, 2025 02:59
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 31, 2025

Open in StackBlitz

npm i https://pkg.pr.new/Azure/typespec-azure/@azure-tools/typespec-client-generator-core@3708

commit: 936a44c

@msyyc msyyc marked this pull request as ready for review December 31, 2025 03:49
) => DecoratorValidatorCallbacks | void;

/**
* Marks a Long Running Operation (LRO) to have no final state location tracking.
Copy link
Member

Choose a reason for hiding this comment

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

Catching up on this, was this completely agreed upon?
I really don't like this name. It is too descriptive of how you defined that in swagger and not of the behavior we are expecting here.

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.

[TCGC] add a legacy decorator @nullFinalStateVia

3 participants