Skip to content

Commit 903db34

Browse files
Make ProviderTokenArgs immutable in Node and Java
The args object is constructed solely by the SDK and only read inside the consumer callback, so it should not be mutable by consumers. - Java: make fields final, keep only the all-args constructor, and drop the no-arg constructor and the fluent setters. The runtime already builds it via new ProviderTokenArgs(providerName, sessionId). - Node: mark the interface fields readonly. .NET already uses init-only required properties and Rust passes a shared reference, so both are already immutable. Go and Python have no idiomatic readonly equivalent for these DTO shapes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent bf30ae8 commit 903db34

2 files changed

Lines changed: 4 additions & 34 deletions

File tree

java/src/main/java/com/github/copilot/rpc/ProviderTokenArgs.java

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@
1717
@CopilotExperimental
1818
public class ProviderTokenArgs {
1919

20-
private String providerName;
20+
private final String providerName;
2121

22-
private String sessionId;
23-
24-
/**
25-
* Creates an empty argument object.
26-
*/
27-
public ProviderTokenArgs() {
28-
}
22+
private final String sessionId;
2923

3024
/**
3125
* Creates argument object for the named provider.
@@ -54,18 +48,6 @@ public String getProviderName() {
5448
return providerName;
5549
}
5650

57-
/**
58-
* Sets the name of the BYOK provider needing a token.
59-
*
60-
* @param providerName
61-
* the provider name
62-
* @return this args instance for method chaining
63-
*/
64-
public ProviderTokenArgs setProviderName(String providerName) {
65-
this.providerName = providerName;
66-
return this;
67-
}
68-
6951
/**
7052
* Gets the id of the session that triggered this token request.
7153
* <p>
@@ -78,16 +60,4 @@ public ProviderTokenArgs setProviderName(String providerName) {
7860
public String getSessionId() {
7961
return sessionId;
8062
}
81-
82-
/**
83-
* Sets the id of the session that triggered this token request.
84-
*
85-
* @param sessionId
86-
* the session id
87-
* @return this args instance for method chaining
88-
*/
89-
public ProviderTokenArgs setSessionId(String sessionId) {
90-
this.sessionId = sessionId;
91-
return this;
92-
}
9363
}

nodejs/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,15 +2230,15 @@ export interface ProviderTokenArgs {
22302230
* The callback closes over its own token scope/audience; the runtime is
22312231
* provider-agnostic and forwards only the provider name.
22322232
*/
2233-
providerName: string;
2233+
readonly providerName: string;
22342234

22352235
/**
22362236
* Id of the session that triggered this token request. A client-level shared
22372237
* callback registered for many sessions can use this to resolve the owning
22382238
* session (e.g. via the client's session lookup) to scope token acquisition
22392239
* or caching per session.
22402240
*/
2241-
sessionId: string;
2241+
readonly sessionId: string;
22422242
}
22432243

22442244
/**

0 commit comments

Comments
 (0)