Skip to content

Commit e2fae0d

Browse files
authored
feat(unstable): Remove unused auth_methods from Error type (#708)
1 parent a21a474 commit e2fae0d

4 files changed

Lines changed: 9 additions & 115 deletions

File tree

docs/protocol/draft/schema.mdx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,27 +2501,18 @@ See protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification
25012501

25022502
**Properties:**
25032503

2504-
<ResponseField name="authMethods" type={<a href="#authmethod">AuthMethod[]</a>} >
2505-
**UNSTABLE**
2506-
2507-
This capability is not part of the spec yet, and may be removed or changed at any point.
2508-
2509-
Authentication methods relevant to this error.
2510-
Typically included with `AUTH_REQUIRED` errors to narrow down which
2511-
authentication methods are applicable from those shared during initialization.
2512-
2513-
</ResponseField>
25142504
<ResponseField name="code" type={<a href="#errorcode">ErrorCode</a>} required>
2515-
A number indicating the error type that occurred.
2516-
This must be an integer as defined in the JSON-RPC specification.
2505+
A number indicating the error type that occurred. This must be an integer as
2506+
defined in the JSON-RPC specification.
25172507
</ResponseField>
2518-
<ResponseField name="data" type={"object"} >
2519-
Optional primitive or structured value that contains additional information about the error.
2520-
This may include debugging information or context-specific details.
2508+
<ResponseField name="data" type={"object"}>
2509+
Optional primitive or structured value that contains additional information
2510+
about the error. This may include debugging information or context-specific
2511+
details.
25212512
</ResponseField>
25222513
<ResponseField name="message" type={"string"} required>
2523-
A string providing a short description of the error.
2524-
The message should be limited to a concise single sentence.
2514+
A string providing a short description of the error. The message should be
2515+
limited to a concise single sentence.
25252516
</ResponseField>
25262517

25272518
## <span class="font-mono">ErrorCode</span>

docs/rfds/auth-methods.mdx

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -152,29 +152,6 @@ Because `terminal` auth methods require specific client-side support, clients mu
152152

153153
The `env_var` type does not require a capability opt-in since any client can set environment variables when starting a process, we are just providing additional context for the environment variable.
154154

155-
### Auth errors
156-
157-
It might be useful to include a list of AuthMethod ids to the AUTH_REQUIRED JsonRpc error. Why do we need this if they're already shared during `initialize`:
158-
All supported auth methods are shared during `initialize`. When user starts a session, they've already selected a model, which can narrow down a list of options.
159-
160-
```json
161-
{
162-
"jsonrpc": "2.0",
163-
"id": 2,
164-
"error": {
165-
"code": -32000,
166-
"message": "Authentication required",
167-
"authMethods": [
168-
{
169-
"id": "chatgpt",
170-
"name": "Login with ChatGPT",
171-
"description": "Use your ChatGPT login with Codex CLI (requires a paid ChatGPT subscription)"
172-
}
173-
]
174-
}
175-
}
176-
```
177-
178155
## Frequently asked questions
179156

180157
> What questions have arisen over the course of authoring this document or during subsequent discussions?
@@ -189,6 +166,7 @@ There is also an alternative to adding a separate `elicitation` capability, whic
189166

190167
There was a part about elicitations https://github.com/agentclientprotocol/agent-client-protocol/blob/939ef116a1b14016e4e3808b8764237250afa253/docs/rfds/auth.mdx removed it for now, will move to a separate rfd
191168

169+
- 2026-03-09: Remove auth_methods from Error type
192170
- 2026-03-03: Changed `env_var` from single `varName` to structured `vars` array of `AuthEnvVar` objects; simplified field name from `varName` to `name`
193171
- 2026-02-27: Updated to reflect current implementation
194172
- 2026-01-14: Updates based on Core Maintainer discussion

schema/schema.unstable.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,13 +1442,6 @@
14421442
"Error": {
14431443
"description": "JSON-RPC error object.\n\nRepresents an error that occurred during method execution, following the\nJSON-RPC 2.0 error object specification with optional additional data.\n\nSee protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object)",
14441444
"properties": {
1445-
"authMethods": {
1446-
"description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nAuthentication methods relevant to this error.\nTypically included with `AUTH_REQUIRED` errors to narrow down which\nauthentication methods are applicable from those shared during initialization.",
1447-
"items": {
1448-
"$ref": "#/$defs/AuthMethod"
1449-
},
1450-
"type": "array"
1451-
},
14521445
"code": {
14531446
"allOf": [
14541447
{

src/error.rs

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ pub struct Error {
3838
/// This may include debugging information or context-specific details.
3939
#[serde(skip_serializing_if = "Option::is_none")]
4040
pub data: Option<serde_json::Value>,
41-
/// **UNSTABLE**
42-
///
43-
/// This capability is not part of the spec yet, and may be removed or changed at any point.
44-
///
45-
/// Authentication methods relevant to this error.
46-
/// Typically included with `AUTH_REQUIRED` errors to narrow down which
47-
/// authentication methods are applicable from those shared during initialization.
48-
#[cfg(feature = "unstable_auth_methods")]
49-
#[serde(default, skip_serializing_if = "Vec::is_empty", rename = "authMethods")]
50-
pub auth_methods: Vec<crate::AuthMethod>,
5141
}
5242

5343
impl Error {
@@ -60,8 +50,6 @@ impl Error {
6050
code: code.into(),
6151
message: message.into(),
6252
data: None,
63-
#[cfg(feature = "unstable_auth_methods")]
64-
auth_methods: Vec::new(),
6553
}
6654
}
6755

@@ -125,20 +113,6 @@ impl Error {
125113
ErrorCode::AuthRequired.into()
126114
}
127115

128-
/// **UNSTABLE**
129-
///
130-
/// This capability is not part of the spec yet, and may be removed or changed at any point.
131-
///
132-
/// Authentication methods relevant to this error.
133-
/// Typically included with `AUTH_REQUIRED` errors to narrow down which
134-
/// authentication methods are applicable from those shared during initialization.
135-
#[cfg(feature = "unstable_auth_methods")]
136-
#[must_use]
137-
pub fn auth_methods(mut self, auth_methods: Vec<crate::AuthMethod>) -> Self {
138-
self.auth_methods = auth_methods;
139-
self
140-
}
141-
142116
/// A given resource, such as a file, was not found.
143117
#[must_use]
144118
pub fn resource_not_found(uri: Option<String>) -> Self {
@@ -312,16 +286,6 @@ impl Display for Error {
312286
write!(f, ": {pretty}")?;
313287
}
314288

315-
#[cfg(feature = "unstable_auth_methods")]
316-
if !self.auth_methods.is_empty() {
317-
let ids: Vec<&str> = self
318-
.auth_methods
319-
.iter()
320-
.map(|m| m.id().0.as_ref())
321-
.collect();
322-
write!(f, " (auth methods: {})", ids.join(", "))?;
323-
}
324-
325289
Ok(())
326290
}
327291
}
@@ -379,36 +343,4 @@ mod tests {
379343
);
380344
}
381345
}
382-
383-
#[cfg(feature = "unstable_auth_methods")]
384-
#[test]
385-
fn serialize_error_auth_methods() {
386-
use crate::{AuthMethod, AuthMethodAgent};
387-
388-
// Verify auth_methods is omitted when empty
389-
let err = Error::auth_required();
390-
let json = serde_json::to_value(&err).unwrap();
391-
assert!(
392-
!json.as_object().unwrap().contains_key("authMethods"),
393-
"authMethods should be omitted when empty"
394-
);
395-
396-
// Verify auth_methods round-trips when present
397-
let err = Error::auth_required().auth_methods(vec![AuthMethod::Agent(
398-
AuthMethodAgent::new("api-key", "API Key"),
399-
)]);
400-
let json = serde_json::to_value(&err).unwrap();
401-
assert!(
402-
json.as_object().unwrap().contains_key("authMethods"),
403-
"authMethods should be present"
404-
);
405-
assert_eq!(json["authMethods"].as_array().unwrap().len(), 1);
406-
assert_eq!(json["authMethods"][0]["id"], "api-key");
407-
assert_eq!(json["authMethods"][0]["name"], "API Key");
408-
409-
// Verify deserialization
410-
let deserialized: Error = serde_json::from_value(json).unwrap();
411-
assert_eq!(deserialized.auth_methods.len(), 1);
412-
assert_eq!(deserialized.auth_methods[0].id().0.as_ref(), "api-key");
413-
}
414346
}

0 commit comments

Comments
 (0)