Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing protocol errors #7982

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

michael-wb
Copy link
Contributor

What, How & Why?

While creating PR #7981, it was discovered that there were 3 protocol errors defined in baas that were not supported in the client. Added definitions for these 3 errors so they will not display "unknown error".

One of these errors (ProtocolError::edge_reboot) is only intended for the edge server and an assertion will be thrown by the client when it tries to convert this error to a status object.

☑️ ToDos

  • 📝 Changelog update
  • [ ] 🚦 Tests (or not relevant)
  • [ ] C-API, if public C++ API changed
  • [ ] bindgen/spec.yml, if public C++ API changed

@michael-wb michael-wb added the no-jira-ticket Skip checking the PR title for Jira reference label Aug 12, 2024
@michael-wb michael-wb self-assigned this Aug 12, 2024
@cla-bot cla-bot bot added the cla: yes label Aug 12, 2024
@@ -393,6 +393,8 @@ static const constexpr MapElem string_to_error_code[] = {
{"SyncConnectFailed", ErrorCodes::SyncConnectFailed},
{"SyncConnectTimeout", ErrorCodes::SyncConnectTimeout},
{"SyncInvalidSchemaChange", ErrorCodes::SyncInvalidSchemaChange},
{"SyncLocalClockBeforeEpoch", ErrorCodes::SyncLocalClockBeforeEpoch},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was never added to the string_to_error_code array.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the new errors be added to this map? and also assign error categories?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am reusing existing ErrorCode values and the two added to this list were already assigned error categories (they were just left off this list - I just verified the list and the only other one missing is UnknownError this seems to be intentional).

@@ -247,6 +260,8 @@ Status protocol_error_to_status(ProtocolError error_code, std::string_view msg)
case ProtocolError::user_blacklisted:
[[fallthrough]];
case ProtocolError::transact_before_upload:
[[fallthrough]];
case ProtocolError::edge_reboot:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very clearly not unreachable as we reach this point if the server sends us this error code. "Unreachable" specifically means that it's a bug in our code if things ever get to that point.

@@ -393,6 +393,8 @@ static const constexpr MapElem string_to_error_code[] = {
{"SyncConnectFailed", ErrorCodes::SyncConnectFailed},
{"SyncConnectTimeout", ErrorCodes::SyncConnectTimeout},
{"SyncInvalidSchemaChange", ErrorCodes::SyncInvalidSchemaChange},
{"SyncLocalClockBeforeEpoch", ErrorCodes::SyncLocalClockBeforeEpoch},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this error even mean?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an error I added. We use 2015-01-01 as epoch and count the milliseconds since then for the changesets' timestamp. This error is thrown when the local clock is set before that date.

// Error code 299 is reserved as an "unknown session error" in tests
} realm_sync_errno_session_e;

// These errors are intended for the edge server and are an error if received by a sync client
typedef enum realm_sync_errno_edge_e {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should expose errors for the edge server. The only way we could get these is via a bug. I think getting an UnkownError for edge server only errors would be totally acceptable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the edge server and wire protocol errors

Copy link

coveralls-official bot commented Aug 12, 2024

Pull Request Test Coverage Report for Build michael.wilkersonbarker_1333

Details

  • 2 of 5 (40.0%) changed or added relevant lines in 1 file are covered.
  • 82 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-0.01%) to 91.097%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/realm/sync/protocol.cpp 2 5 40.0%
Files with Coverage Reduction New Missed Lines %
src/realm/array_string.cpp 1 88.03%
src/realm/dictionary.cpp 1 85.16%
src/realm/sync/network/websocket.cpp 1 72.2%
src/realm/sync/noinst/server/server.cpp 1 74.72%
test/test_index_string.cpp 1 93.48%
src/realm/sync/noinst/client_impl_base.cpp 2 82.78%
test/object-store/util/test_file.cpp 2 87.06%
src/realm/table.cpp 4 90.42%
test/fuzz_tester.hpp 5 57.18%
src/realm/bplustree.cpp 7 71.41%
Totals Coverage Status
Change from base Build 2561: -0.01%
Covered Lines: 217366
Relevant Lines: 238609

💛 - Coveralls

@michael-wb michael-wb marked this pull request as draft August 26, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes no-jira-ticket Skip checking the PR title for Jira reference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants