Skip to content

Commit f676e11

Browse files
authored
Merge pull request #700 from obeli-sk/webapi-err
refactor(webapi)!: Change the top-level error variant serialization back to `err`
2 parents 7ecc63d + b315a3a commit f676e11

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

assets/schemas/openapi.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,10 +2542,10 @@
25422542
"type": "object",
25432543
"description": "Error result (WIT result's error variant)",
25442544
"required": [
2545-
"error"
2545+
"err"
25462546
],
25472547
"properties": {
2548-
"error": {
2548+
"err": {
25492549
"type": [
25502550
"object",
25512551
"null"

src/command/integration_tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,7 @@ async fn activity_js_fetch_denied() {
21892189
.await;
21902190
assert_eq!(resp.status().as_u16(), 201);
21912191
let body: Value = resp.json().await.unwrap();
2192-
let err = body["error"].as_str().expect("expected error field");
2192+
let err = body["err"].as_str().expect("expected err field");
21932193
assert!(
21942194
err.contains("HttpRequestDenied"),
21952195
"Expected error to contain 'HttpRequestDenied', got: {err}"
@@ -2255,8 +2255,8 @@ async fn activity_js_throw_null_void_err() {
22552255
.await;
22562256
assert_eq!(resp.status().as_u16(), 201);
22572257
let body: Value = resp.json().await.unwrap();
2258-
// `throw null` with void err channel → Err(None) → {"error": null}
2259-
assert_eq!(body, json!({ "error": null }));
2258+
// `throw null` with void err channel → Err(None) → {"err": null}
2259+
assert_eq!(body, json!({ "err": null }));
22602260
server.shutdown().await;
22612261
}
22622262

@@ -2271,7 +2271,7 @@ async fn activity_js_variant_err_throw() {
22712271
.await;
22722272
assert_eq!(resp.status().as_u16(), 201);
22732273
let body: Value = resp.json().await.unwrap();
2274-
assert_eq!(body, json!({ "error": "not_found" }));
2274+
assert_eq!(body, json!({ "err": "not_found" }));
22752275
server.shutdown().await;
22762276
}
22772277

@@ -2301,15 +2301,15 @@ async fn workflow_js_rich_return_type() {
23012301
.await;
23022302
assert_eq!(resp.status().as_u16(), 201);
23032303
let body: Value = resp.json().await.unwrap();
2304-
assert_eq!(body, json!({ "error": "not_found" }));
2304+
assert_eq!(body, json!({ "err": "not_found" }));
23052305

23062306
// err: null (void err channel — result<string>)
23072307
let resp = server
23082308
.submit_follow("testing:integration/workflow-throw-null.throw-null", vec![])
23092309
.await;
23102310
assert_eq!(resp.status().as_u16(), 201);
23112311
let body: Value = resp.json().await.unwrap();
2312-
assert_eq!(body, json!({ "error": null }));
2312+
assert_eq!(body, json!({ "err": null }));
23132313
server.shutdown().await;
23142314
}
23152315

@@ -3220,7 +3220,7 @@ async fn activity_exec_void_err() {
32203220
.await;
32213221
assert_eq!(resp.status().as_u16(), 201);
32223222
let body: Value = resp.json().await.unwrap();
3223-
assert_eq!(body, json!({ "error": null }));
3223+
assert_eq!(body, json!({ "err": null }));
32243224
server.shutdown().await;
32253225
}
32263226

@@ -3261,7 +3261,7 @@ async fn activity_exec_error_exit() {
32613261
.await;
32623262
assert_eq!(resp.status().as_u16(), 201);
32633263
let body: Value = resp.json().await.unwrap();
3264-
assert_eq!(body, json!({ "error": "something went wrong" }));
3264+
assert_eq!(body, json!({ "err": "something went wrong" }));
32653265
server.shutdown().await;
32663266
}
32673267

src/server/web_api_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ enum RetVal {
14281428
Ok(Option<WastVal>),
14291429
/// Error result (WIT result's error variant)
14301430
#[schema(value_type = Option<Object>)]
1431-
Error(Option<WastVal>),
1431+
Err(Option<WastVal>),
14321432
/// Execution failed
14331433
#[schema(value_type = Object)]
14341434
ExecutionFailure(FinishedExecutionFailure),
@@ -1440,7 +1440,7 @@ impl From<SupportedFunctionReturnValue> for RetVal {
14401440
RetVal::Ok(val_with_type.map(|it| it.value))
14411441
}
14421442
SupportedFunctionReturnValue::Err(val_with_type) => {
1443-
RetVal::Error(val_with_type.map(|it| it.value))
1443+
RetVal::Err(val_with_type.map(|it| it.value))
14441444
}
14451445
SupportedFunctionReturnValue::ExecutionFailure(err) => RetVal::ExecutionFailure(err),
14461446
}

0 commit comments

Comments
 (0)