Skip to content

Add missing protocol errors#7982

Closed
michael-wb wants to merge 4 commits intomasterfrom
mwb/update-protocol-errors
Closed

Add missing protocol errors#7982
michael-wb wants to merge 4 commits intomasterfrom
mwb/update-protocol-errors

Conversation

@michael-wb
Copy link
Copy Markdown
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
Comment thread src/realm/error_codes.cpp
{"SyncConnectFailed", ErrorCodes::SyncConnectFailed},
{"SyncConnectTimeout", ErrorCodes::SyncConnectTimeout},
{"SyncInvalidSchemaChange", ErrorCodes::SyncInvalidSchemaChange},
{"SyncLocalClockBeforeEpoch", ErrorCodes::SyncLocalClockBeforeEpoch},
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

💯

Copy link
Copy Markdown
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
Copy Markdown
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).

Comment thread src/realm/sync/protocol.cpp Outdated
[[fallthrough]];
case ProtocolError::transact_before_upload:
[[fallthrough]];
case ProtocolError::edge_reboot:
Copy link
Copy Markdown
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.

Comment thread src/realm/error_codes.cpp
{"SyncConnectFailed", ErrorCodes::SyncConnectFailed},
{"SyncConnectTimeout", ErrorCodes::SyncConnectTimeout},
{"SyncInvalidSchemaChange", ErrorCodes::SyncInvalidSchemaChange},
{"SyncLocalClockBeforeEpoch", ErrorCodes::SyncLocalClockBeforeEpoch},
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/realm/error_codes.h Outdated
} 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
Copy Markdown
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
Copy Markdown
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

@coveralls-official
Copy link
Copy Markdown

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
@michael-wb michael-wb closed this Dec 30, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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