diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fb1662db8..185ed50ad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ ### Internals * Update TestAppSession to allow scope-based usage for restarting the local app resources. ([PR #7672](https://github.com/realm/realm-core/pull/7672)) +* Added definitions for missing protocol errors reported by the server. ([PR #7982](https://github.com/realm/realm-core/pull/7982)) ---------------------------------------------- diff --git a/src/realm/error_codes.cpp b/src/realm/error_codes.cpp index d137afc28f..b3aa6b64c9 100644 --- a/src/realm/error_codes.cpp +++ b/src/realm/error_codes.cpp @@ -393,9 +393,11 @@ static const constexpr MapElem string_to_error_code[] = { {"SyncConnectFailed", ErrorCodes::SyncConnectFailed}, {"SyncConnectTimeout", ErrorCodes::SyncConnectTimeout}, {"SyncInvalidSchemaChange", ErrorCodes::SyncInvalidSchemaChange}, + {"SyncLocalClockBeforeEpoch", ErrorCodes::SyncLocalClockBeforeEpoch}, {"SyncPermissionDenied", ErrorCodes::SyncPermissionDenied}, {"SyncProtocolInvariantFailed", ErrorCodes::SyncProtocolInvariantFailed}, {"SyncProtocolNegotiationFailed", ErrorCodes::SyncProtocolNegotiationFailed}, + {"SyncSchemaMigrationError", ErrorCodes::SyncSchemaMigrationError}, {"SyncServerPermissionsChanged", ErrorCodes::SyncServerPermissionsChanged}, {"SyncUserMismatch", ErrorCodes::SyncUserMismatch}, {"SyncWriteNotAllowed", ErrorCodes::SyncWriteNotAllowed}, @@ -407,6 +409,7 @@ static const constexpr MapElem string_to_error_code[] = { {"TwilioError", ErrorCodes::TwilioError}, {"TypeMismatch", ErrorCodes::TypeMismatch}, {"UnexpectedPrimaryKey", ErrorCodes::UnexpectedPrimaryKey}, + // UnknownError intentionally left out of list {"UnsupportedFileFormatVersion", ErrorCodes::UnsupportedFileFormatVersion}, {"UserAlreadyConfirmed", ErrorCodes::UserAlreadyConfirmed}, {"UserAppDomainMismatch", ErrorCodes::UserAppDomainMismatch}, diff --git a/src/realm/error_codes.h b/src/realm/error_codes.h index 4b0a85bcd8..e27fe366e6 100644 --- a/src/realm/error_codes.h +++ b/src/realm/error_codes.h @@ -266,6 +266,9 @@ typedef enum realm_sync_errno_session { RLM_SYNC_ERR_SESSION_REVERT_TO_PBS = 234, RLM_SYNC_ERR_SESSION_BAD_SCHEMA_VERSION = 235, RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_CHANGED = 236, + // Error code 237 is not used by the client + // Error code 238 is not used by the sync protocol + RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_FORCE_UPGRADE = 239, // Error code 299 is reserved as an "unknown session error" in tests } realm_sync_errno_session_e; diff --git a/src/realm/sync/protocol.cpp b/src/realm/sync/protocol.cpp index 525604f785..7803403e86 100644 --- a/src/realm/sync/protocol.cpp +++ b/src/realm/sync/protocol.cpp @@ -128,6 +128,9 @@ const char* get_protocol_error_message(int error_code) noexcept case ProtocolError::schema_version_changed: return "Client opened a session with a new valid schema version - migrating client to use new schema " "version (BIND)"; + case ProtocolError::schema_version_force_upgrade: + return "Server has forcefully bumped client's schema version because it does not support schema " + "versioning"; } return nullptr; } @@ -222,6 +225,8 @@ Status protocol_error_to_status(ProtocolError error_code, std::string_view msg) case ProtocolError::bad_schema_version: [[fallthrough]]; case ProtocolError::schema_version_changed: + [[fallthrough]]; + case ProtocolError::schema_version_force_upgrade: return ErrorCodes::SyncSchemaMigrationError; case ProtocolError::limits_exceeded: diff --git a/src/realm/sync/protocol.hpp b/src/realm/sync/protocol.hpp index eab452bdf2..005a672f6e 100644 --- a/src/realm/sync/protocol.hpp +++ b/src/realm/sync/protocol.hpp @@ -425,6 +425,7 @@ enum class ProtocolError { revert_to_pbs = RLM_SYNC_ERR_SESSION_REVERT_TO_PBS, // Server rolled back to PBS after FLX migration - revert FLX client migration (BIND) bad_schema_version = RLM_SYNC_ERR_SESSION_BAD_SCHEMA_VERSION, // Client tried to open a session with an invalid schema version (BIND) schema_version_changed = RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_CHANGED, // Client opened a session with a new valid schema version - migrate client to use new schema version (BIND) + schema_version_force_upgrade = RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_FORCE_UPGRADE, // Server has forcefully bumped client's schema version because it does not support schema versioning // clang-format on };