diff --git a/aimdb-client/README.md b/aimdb-client/README.md index 0d7fbc43..44252f57 100644 --- a/aimdb-client/README.md +++ b/aimdb-client/README.md @@ -61,6 +61,16 @@ frames mapping onto the session engine's role-neutral message set. It declares version, so a 3.x peer is refused at the handshake (and a WebSocket upgrade with `?v=3.x`). +### RPC errors + +Error replies have the shape `{"t":"reply","id":N,"err":CODE,"msg"?}`. +`not_found`, `unsupported`, `denied` and `internal` describe record lookup, +capability, permission and engine/transport failures. `invalid_value` means the +request was understood but the record's type or codec rejected the supplied +value; the optional `msg` carries the deserializer's explanation, and no write +was applied. Decoders map an unknown future `err` code to `internal`, so adding +codes remains backward-compatible. + ### Write timestamps (AimX 4.0) Every record value on the wire carries `ts`, the time it was written into the diff --git a/aimdb-client/src/engine.rs b/aimdb-client/src/engine.rs index 54b18389..3b3d631f 100644 --- a/aimdb-client/src/engine.rs +++ b/aimdb-client/src/engine.rs @@ -589,6 +589,9 @@ fn rpc_err(e: RpcError) -> ClientError { use drain_record for unread events or subscribe for new ones)", None, ), + RpcError::InvalidValue(message) => { + ClientError::server_error("invalid_value", message, None) + } // `Internal` today, plus any future non-exhaustive variant. _ => ClientError::server_error("internal", "engine/transport failure", None), } @@ -847,4 +850,18 @@ mod tests { ClientError::ServerError { code, .. } if code == "denied" )); } + + #[test] + fn a_rejected_record_value_keeps_its_own_code_and_detail() { + let err = rpc_err(RpcError::InvalidValue( + "list exceeds maximum length of 2".to_string(), + )); + match err { + ClientError::ServerError { code, message, .. } => { + assert_eq!(code, "invalid_value"); + assert_eq!(message, "list exceeds maximum length of 2"); + } + other => panic!("expected ServerError, got {other:?}"), + } + } } diff --git a/aimdb-client/tests/aimx_session.rs b/aimdb-client/tests/aimx_session.rs index de46fcb4..ece37822 100644 --- a/aimdb-client/tests/aimx_session.rs +++ b/aimdb-client/tests/aimx_session.rs @@ -167,6 +167,76 @@ async fn aimx_roundtrip_over_uds_production_server() { drop(conn); // stops the client engine } +/// A value the record rejects is a caller error, not an engine/transport +/// failure, and the healthy session accepts a corrected write afterwards. +#[tokio::test] +async fn rejected_record_value_is_invalid_value_and_keeps_the_session_alive() { + let key_setting = aimdb_core::Name::::new("setting"); + let dir = tempfile::tempdir().unwrap(); + let sock = dir.path().join("aimdb.sock"); + + let mut policy = SecurityPolicy::read_write(); + policy.allow_write_key("setting"); + let config = AimxConfig::uds_default() + .socket_path(sock.to_str().unwrap()) + .security_policy(policy); + + let mut builder = AimDbBuilder::new() + .runtime(Arc::new(TokioAdapter)) + .with_connector(UdsServer::from_config(config)); + builder.configure(key_setting, |reg| { + reg.buffer(BufferCfg::SingleLatest).with_remote_access(); + }); + let (_db, runner) = builder.build().await.expect("build db"); + tokio::spawn(runner.run()); + + let conn = tokio::time::timeout( + Duration::from_secs(5), + AimxConnection::connect(sock.to_str().unwrap()), + ) + .await + .expect("connect timed out") + .expect("connect"); + tokio::time::timeout( + Duration::from_secs(5), + conn.set_record("setting", json!({ "level": 7 })), + ) + .await + .expect("initial accepted set timed out") + .expect("the initial value succeeds"); + let err = tokio::time::timeout( + Duration::from_secs(5), + conn.set_record("setting", json!({ "level": "seven" })), + ) + .await + .expect("rejected set timed out") + .expect_err("the record rejects a string for u64"); + match err { + aimdb_client::ClientError::ServerError { code, message, .. } => { + assert_eq!(code, "invalid_value"); + assert!(message.contains("invalid type"), "{message}"); + } + other => panic!("expected a typed server error, got {other:?}"), + } + + let unchanged = tokio::time::timeout(Duration::from_secs(5), conn.get_record("setting")) + .await + .expect("read after rejected set timed out") + .expect("read after rejected set"); + assert_eq!(unchanged.value["level"], 7); + + let reply = tokio::time::timeout( + Duration::from_secs(5), + conn.set_record("setting", json!({ "level": 8 })), + ) + .await + .expect("accepted set timed out") + .expect("a corrected value succeeds on the same connection"); + assert_eq!(reply["value"], json!({ "level": 8 })); + + drop(conn); +} + /// One wildcard subscription fans in every matching record: events arrive /// tagged with the concrete record topic, and matched records with a current /// value are delivered up front as snapshots. diff --git a/aimdb-core/src/codec.rs b/aimdb-core/src/codec.rs index 3ba945d8..3414bea9 100644 --- a/aimdb-core/src/codec.rs +++ b/aimdb-core/src/codec.rs @@ -23,6 +23,7 @@ //! `RecordValue::as_json` route through it. This mirrors the connector //! layer's typed route and `IngestFn` callbacks. +use alloc::string::{String, ToString}; use alloc::vec::Vec; use serde::{de::DeserializeOwned, Serialize}; @@ -39,6 +40,17 @@ pub trait RemoteSerialize: Sized { /// Deserialize a JSON value into `Self`, or `None` on schema mismatch. fn from_json(value: &serde_json::Value) -> Option; + /// Deserialize a JSON value into `Self`, or explain why it was rejected. + /// + /// The default keeps manual [`RemoteSerialize`] implementations source- + /// compatible but cannot recover a specific reason from [`from_json`]. + /// The blanket Serde implementation overrides this and preserves the + /// deserializer's message for remote-callers. + fn from_json_with_error(value: &serde_json::Value) -> Result { + Self::from_json(value) + .ok_or_else(|| String::from("the record's JSON codec rejected the value")) + } + /// Serialize this value to owned JSON bytes. /// /// The default preserves compatibility with manual implementations by @@ -59,6 +71,17 @@ pub trait RemoteSerialize: Sized { let value = serde_json::from_slice(bytes).ok()?; Self::from_json(&value) } + + /// Deserialize one complete JSON value from `bytes`, or explain the + /// rejection. The blanket Serde implementation preserves both parse and + /// deserialize errors; manual codecs inherit the generic fallback. + fn from_json_slice_with_error(bytes: &[u8]) -> Result { + if let Some(value) = Self::from_json_slice(bytes) { + return Ok(value); + } + let value = serde_json::from_slice(bytes).map_err(|e| e.to_string())?; + Self::from_json_with_error(&value) + } } impl RemoteSerialize for T @@ -73,6 +96,10 @@ where serde_json::from_value(value.clone()).ok() } + fn from_json_with_error(value: &serde_json::Value) -> Result { + serde_json::from_value(value.clone()).map_err(|e| e.to_string()) + } + fn to_json_vec(&self) -> Option> { serde_json::to_vec(self).ok() } @@ -80,6 +107,10 @@ where fn from_json_slice(bytes: &[u8]) -> Option { serde_json::from_slice(bytes).ok() } + + fn from_json_slice_with_error(bytes: &[u8]) -> Result { + serde_json::from_slice(bytes).map_err(|e| e.to_string()) + } } /// Type-erased JSON codec for one record type. @@ -95,6 +126,16 @@ pub trait JsonCodec: Send + Sync { /// Decode a JSON value into `T`, or `None` on schema mismatch. fn decode(&self, value: &serde_json::Value) -> Option; + /// Decode a JSON value into `T`, or explain why the codec rejected it. + /// + /// Existing custom codecs keep implementing only [`decode`](Self::decode); + /// they inherit a generic error. [`SerdeJsonCodec`] overrides this to carry + /// the underlying deserializer message. + fn decode_with_error(&self, value: &serde_json::Value) -> Result { + self.decode(value) + .ok_or_else(|| String::from("the record's JSON codec rejected the value")) + } + /// Encode a typed value into owned JSON bytes. /// /// Defaulted through [`encode`](Self::encode) so existing custom codecs @@ -111,6 +152,17 @@ pub trait JsonCodec: Send + Sync { let value = serde_json::from_slice(bytes).ok()?; self.decode(&value) } + + /// Decode one complete JSON value from a byte slice, or explain the + /// rejection. Custom codecs inherit a parser error followed by the generic + /// [`decode_with_error`](Self::decode_with_error) fallback. + fn decode_slice_with_error(&self, bytes: &[u8]) -> Result { + if let Some(value) = self.decode_slice(bytes) { + return Ok(value); + } + let value = serde_json::from_slice(bytes).map_err(|e| e.to_string())?; + self.decode_with_error(&value) + } } /// Zero-sized serde-backed [`JsonCodec`]. @@ -129,6 +181,10 @@ impl JsonCodec for SerdeJsonCodec { T::from_json(value) } + fn decode_with_error(&self, value: &serde_json::Value) -> Result { + T::from_json_with_error(value) + } + fn encode_to_vec(&self, value: &T) -> Option> { value.to_json_vec() } @@ -136,6 +192,10 @@ impl JsonCodec for SerdeJsonCodec { fn decode_slice(&self, bytes: &[u8]) -> Option { T::from_json_slice(bytes) } + + fn decode_slice_with_error(&self, bytes: &[u8]) -> Result { + T::from_json_slice_with_error(bytes) + } } #[cfg(test)] @@ -243,4 +303,29 @@ mod tests { ); } } + + #[test] + fn serde_codec_preserves_the_rejection_reason() { + let value_error = >::decode_with_error( + &SerdeJsonCodec, + &json!("not a number"), + ) + .unwrap_err(); + assert!(value_error.contains("invalid type"), "{value_error}"); + + let parse_error = >::decode_slice_with_error( + &SerdeJsonCodec, + b"not json", + ) + .unwrap_err(); + assert!(parse_error.contains("expected ident"), "{parse_error}"); + } + + #[test] + fn custom_codecs_keep_working_with_a_generic_rejection_reason() { + let reason = TreeOnlyCodec + .decode_with_error(&json!({ "name": 7 })) + .unwrap_err(); + assert_eq!(reason, "the record's JSON codec rejected the value"); + } } diff --git a/aimdb-core/src/error.rs b/aimdb-core/src/error.rs index 6d2bdf9b..5b2ef339 100644 --- a/aimdb-core/src/error.rs +++ b/aimdb-core/src/error.rs @@ -151,6 +151,19 @@ pub enum DbError { #[error("Invalid operation '{operation}': {reason}")] InvalidOperation { operation: String, reason: String }, + /// A remote value did not match the record's type or failed its validation. + /// + /// This is a caller error: the engine and transport are healthy, and the + /// write was not applied. `reason` is the codec/deserializer's explanation + /// when available. + #[error("Invalid value for record type '{type_name}': {reason}")] + InvalidRecordValue { + /// Fully qualified record value type, for diagnostics. + type_name: String, + /// Why the record's codec rejected the value. + reason: String, + }, + /// Permission denied for operation #[error("Permission denied: {operation}")] PermissionDenied { operation: String }, @@ -249,6 +262,14 @@ impl DbError { } } + /// Builds an [`InvalidRecordValue`](DbError::InvalidRecordValue). + pub fn invalid_record_value(type_name: impl Into, reason: impl Into) -> Self { + DbError::InvalidRecordValue { + type_name: type_name.into(), + reason: reason.into(), + } + } + /// Builds a [`RecordKeyNotFound`](DbError::RecordKeyNotFound). pub fn record_key_not_found(key: impl Into) -> Self { DbError::RecordKeyNotFound { key: key.into() } @@ -323,6 +344,8 @@ impl DbError { | Self::InvalidOperation { .. } | Self::PermissionDenied { .. } => DbErrorKind::Usage, + Self::InvalidRecordValue { .. } => DbErrorKind::Data, + Self::RuntimeError { .. } | Self::Internal { .. } => DbErrorKind::Internal, #[cfg(feature = "std")] @@ -403,6 +426,10 @@ mod tests { DbError::permission_denied("write"), DbError::PermissionDenied { .. } )); + assert!(matches!( + DbError::invalid_record_value("Temperature", "expected f32"), + DbError::InvalidRecordValue { .. } + )); assert!(matches!( DbError::record_key_not_found("k"), DbError::RecordKeyNotFound { .. } @@ -509,6 +536,10 @@ mod tests { Usage ); assert_eq!(DbError::permission_denied("op").kind(), Usage); + assert_eq!( + DbError::invalid_record_value("Temperature", "expected f32").kind(), + Data + ); assert_eq!(DbError::runtime_error("m").kind(), Internal); assert_eq!( diff --git a/aimdb-core/src/session/aimx/codec.rs b/aimdb-core/src/session/aimx/codec.rs index 6bf1e1ce..3614184e 100644 --- a/aimdb-core/src/session/aimx/codec.rs +++ b/aimdb-core/src/session/aimx/codec.rs @@ -22,6 +22,8 @@ //! verbatim via [`serde_json::value::RawValue`] — no intermediate `Value` tree, //! no re-escaping. +use alloc::borrow::Cow; +use alloc::string::ToString; use alloc::sync::Arc; use alloc::vec::Vec; @@ -70,6 +72,10 @@ struct Frame<'a> { ok: Option<&'a RawValue>, #[serde(default, borrow, skip_serializing_if = "Option::is_none")] err: Option<&'a str>, + /// Optional human-readable explanation alongside `err`. Reserved by the + /// AimX envelope and currently used for `invalid_value`. + #[serde(default, borrow, skip_serializing_if = "Option::is_none")] + msg: Option>, } impl<'a> Frame<'a> { @@ -89,6 +95,7 @@ impl<'a> Frame<'a> { data: None, ok: None, err: None, + msg: None, } } } @@ -148,6 +155,7 @@ fn err_code(e: &RpcError) -> &'static str { match e { RpcError::NotFound => "not_found", RpcError::Unsupported => "unsupported", + RpcError::InvalidValue(_) => "invalid_value", RpcError::Denied => "denied", RpcError::Internal => "internal", RpcError::VersionMismatch => "version_mismatch", @@ -156,10 +164,22 @@ fn err_code(e: &RpcError) -> &'static str { } } -fn code_err(s: &str) -> RpcError { +fn err_msg(e: &RpcError) -> Option<&str> { + match e { + RpcError::InvalidValue(message) => Some(message.as_str()), + _ => None, + } +} + +fn code_err(s: &str, msg: Option<&str>) -> RpcError { match s { "not_found" => RpcError::NotFound, "unsupported" => RpcError::Unsupported, + "invalid_value" => RpcError::InvalidValue( + msg.filter(|message| !message.is_empty()) + .unwrap_or("the record rejected the value") + .to_string(), + ), "denied" => RpcError::Denied, "version_mismatch" => RpcError::VersionMismatch, _ => RpcError::Internal, @@ -272,6 +292,7 @@ impl EnvelopeCodec for AimxCodec { } Err(e) => { frame.err = Some(err_code(e)); + frame.msg = err_msg(e).map(Cow::Borrowed); write_frame(out, &frame) } } @@ -367,7 +388,7 @@ impl EnvelopeCodec for AimxCodec { let id = f.id.ok_or(CodecError::Malformed)?; let result = match (f.ok, f.err) { (Some(_), _) => Ok(payload_of(f.ok)), - (None, Some(code)) => Err(code_err(code)), + (None, Some(code)) => Err(code_err(code, f.msg.as_deref())), (None, None) => return Err(CodecError::Malformed), }; Ok(Outbound::Reply { id, result }) @@ -518,6 +539,7 @@ mod tests { for err in [ RpcError::NotFound, RpcError::Unsupported, + RpcError::InvalidValue("expected u32".to_string()), RpcError::Denied, RpcError::Internal, RpcError::VersionMismatch, @@ -533,6 +555,57 @@ mod tests { } } + #[test] + fn invalid_value_carries_its_reason_and_unknown_codes_stay_compatible() { + let frame = encode_outbound(Outbound::Reply { + id: 9, + result: Err(RpcError::InvalidValue( + "invalid type: string \"seven\", expected u64".to_string(), + )), + }); + let text = core::str::from_utf8(&frame).unwrap(); + assert!(text.contains(r#""err":"invalid_value""#), "{text}"); + assert!( + text.contains(r#""msg":"invalid type: string \"seven\", expected u64""#), + "{text}" + ); + match AimxCodec.decode_outbound(&frame).unwrap() { + Outbound::Reply { id, result } => { + assert_eq!(id, 9); + assert_eq!( + result.unwrap_err(), + RpcError::InvalidValue( + "invalid type: string \"seven\", expected u64".to_string() + ) + ); + } + _ => panic!("expected Reply"), + } + + // A server can omit the detail; the client still gets the typed code. + let without_detail = + AimxCodec.decode_outbound(br#"{"t":"reply","id":9,"err":"invalid_value"}"#); + assert!(matches!( + without_detail, + Ok(Outbound::Reply { + result: Err(RpcError::InvalidValue(_)), + .. + }) + )); + + // Older clients, and this codec against a future server, preserve the + // historical fallback instead of failing the frame. + let future_code = AimxCodec + .decode_outbound(br#"{"t":"reply","id":9,"err":"some_future_code","msg":"detail"}"#); + assert!(matches!( + future_code, + Ok(Outbound::Reply { + result: Err(RpcError::Internal), + .. + }) + )); + } + #[test] fn event_roundtrip_without_topic() { let frame = encode_outbound(Outbound::Event { diff --git a/aimdb-core/src/session/aimx/dispatch.rs b/aimdb-core/src/session/aimx/dispatch.rs index 568fedee..ee4b5c54 100644 --- a/aimdb-core/src/session/aimx/dispatch.rs +++ b/aimdb-core/src/session/aimx/dispatch.rs @@ -554,6 +554,9 @@ fn map_post_link_err(e: crate::remote::PostLinkError) -> RpcError { fn map_db_err(e: DbError) -> RpcError { match e { DbError::RecordKeyNotFound { .. } | DbError::InvalidRecordId { .. } => RpcError::NotFound, + DbError::InvalidRecordValue { type_name, reason } => RpcError::InvalidValue( + alloc::format!("invalid value for record type '{type_name}': {reason}"), + ), DbError::PermissionDenied { .. } => RpcError::Denied, _ => RpcError::Internal, } @@ -752,6 +755,85 @@ mod tests { Ok(serde_json::from_slice(&reply).expect("reply is JSON")) } + #[tokio::test] + async fn record_set_reports_a_rejected_value_without_blaming_the_engine() { + struct LatestBuffer(Mutex>>); + struct EmptyReader; + + impl crate::buffer::BufferReader> for EmptyReader { + fn poll_recv( + &mut self, + _cx: &mut core::task::Context<'_>, + ) -> core::task::Poll, DbError>> { + core::task::Poll::Ready(Err(DbError::BufferEmpty)) + } + + fn try_recv(&mut self) -> Result, DbError> { + Err(DbError::BufferEmpty) + } + } + + impl crate::buffer::DynBuffer> for LatestBuffer { + fn push(&self, value: Stamped) { + *self.0.lock().expect("latest buffer lock") = Some(value); + } + + fn subscribe_boxed(&self) -> Box> + Send> { + Box::new(EmptyReader) + } + + fn as_any(&self) -> &dyn core::any::Any { + self + } + + fn peek(&self) -> Option> { + self.0.lock().expect("latest buffer lock").clone() + } + } + + let key = crate::Name::::new("config.value"); + let mut builder = crate::AimDbBuilder::new() + .runtime(Arc::new(crate::executor::test_support::NoopRuntimeOps)); + builder.configure(key, |reg| { + reg.buffer_with_cfg( + Box::new(LatestBuffer(Mutex::new(None))), + crate::buffer::BufferCfg::SingleLatest, + ) + .with_remote_access(); + }); + let (db, _runner) = builder.build().await.expect("build db"); + let config = AimxConfig::uds_default() + .security_policy(SecurityPolicy::read_write().with_writable_key("config.value")); + let dispatch = AimxDispatch::new(Arc::new(db), config); + let mut session = dispatch.open(&SessionCtx::default()); + + let err = call( + &mut session, + "record.set", + json!({ "name": "config.value", "value": "not a number" }), + ) + .await + .expect_err("the record must reject the value"); + match err { + RpcError::InvalidValue(message) => { + assert!(message.contains("u32"), "{message}"); + assert!(message.contains("invalid type"), "{message}"); + } + other => panic!("expected InvalidValue, got {other:?}"), + } + + // A caller mistake must not tear down the session or poison later writes. + let reply = call( + &mut session, + "record.set", + json!({ "name": "config.value", "value": 7 }), + ) + .await + .expect("the session remains usable"); + assert_eq!(reply["status"], "success"); + assert_eq!(reply["value"], json!(7)); + } + const PAYLOAD: &[u8] = br#"{"schema":1,"name":"boiler-gateway","version":"1.4.0","ext":{"board":"h563"}}"#; diff --git a/aimdb-core/src/session/mod.rs b/aimdb-core/src/session/mod.rs index 56dea973..afabb9ec 100644 --- a/aimdb-core/src/session/mod.rs +++ b/aimdb-core/src/session/mod.rs @@ -273,6 +273,12 @@ pub enum RpcError { /// The method exists but the target cannot serve it, e.g. `record.get` on /// a ring buffer, which has no current value to read. Unsupported, + /// The caller supplied a value the record's type or codec rejected. + /// + /// The request was understood and the session/transport are healthy; no + /// write was applied. The string carries the codec's explanation when the + /// server provides one. + InvalidValue(String), /// The caller lacks permission for this operation. Denied, /// The handler failed. diff --git a/aimdb-core/src/typed_record.rs b/aimdb-core/src/typed_record.rs index e5e27474..f44b441e 100644 --- a/aimdb-core/src/typed_record.rs +++ b/aimdb-core/src/typed_record.rs @@ -1534,13 +1534,9 @@ impl JsonRecordAccess for TypedRecord< let codec = self.remote_write_codec("set_from_json")?; - let value: T = codec.decode(&json_value).ok_or_else(|| { - DbError::runtime_error(alloc::format!( - "Failed to deserialize JSON to type '{}'. \ - JSON structure does not match the expected schema.", - core::any::type_name::() - )) - })?; + let value: T = codec + .decode_with_error(&json_value) + .map_err(|reason| DbError::invalid_record_value(core::any::type_name::(), reason))?; self.commit_remote_write(value) } @@ -1554,13 +1550,9 @@ impl JsonRecordAccess for TypedRecord< ); let codec = self.remote_write_codec("set_from_json_bytes")?; - let value: T = codec.decode_slice(bytes).ok_or_else(|| { - DbError::runtime_error(alloc::format!( - "Failed to deserialize JSON to type '{}'. \ - JSON structure does not match the expected schema.", - core::any::type_name::() - )) - })?; + let value: T = codec + .decode_slice_with_error(bytes) + .map_err(|reason| DbError::invalid_record_value(core::any::type_name::(), reason))?; self.commit_remote_write(value) } @@ -1737,4 +1729,32 @@ mod tests { assert!(capture::with(observer, || record.set_from_json(serde_json::json!(7))).is_err()); assert!(seen.load(core::sync::atomic::Ordering::Relaxed)); } + + #[test] + fn remote_write_decode_failures_are_invalid_values_with_details() { + let mut record = TypedRecord::::new(); + record.with_remote_access(); + record.buffer = Some(Arc::new(PeekBuffer(0))); + + let err = record + .set_from_json(serde_json::json!("not a number")) + .unwrap_err(); + match err { + crate::DbError::InvalidRecordValue { type_name, reason } => { + assert_eq!(type_name, core::any::type_name::()); + assert!(reason.contains("invalid type"), "{reason}"); + } + other => panic!("expected InvalidRecordValue, got {other:?}"), + } + + let err = record + .set_from_json_bytes(br#""not a number""#) + .unwrap_err(); + match err { + crate::DbError::InvalidRecordValue { reason, .. } => { + assert!(reason.contains("invalid type"), "{reason}"); + } + other => panic!("expected InvalidRecordValue, got {other:?}"), + } + } } diff --git a/aimdb-wasm-adapter/src/ws_bridge.rs b/aimdb-wasm-adapter/src/ws_bridge.rs index ecac85a5..52ee0a53 100644 --- a/aimdb-wasm-adapter/src/ws_bridge.rs +++ b/aimdb-wasm-adapter/src/ws_bridge.rs @@ -841,6 +841,7 @@ fn rpc_err_str(e: &RpcError) -> &'static str { match e { RpcError::NotFound => "not_found", RpcError::Unsupported => "unsupported (a ring has no current value)", + RpcError::InvalidValue(_) => "invalid_value (the record rejected the supplied value)", RpcError::Denied => "denied", RpcError::VersionMismatch => { "version_mismatch (server rejected the client protocol version)"