Skip to content

Commit

Permalink
Merge pull request #1639 from atsign-foundation/gkc/fix/gracefully-ha…
Browse files Browse the repository at this point in the history
…ndle-malformed-keys-in-sync-response

fix: In SyncProgressiveVerbHandler.prepareResponse, gracefully handle any malformed keys which happen to be in the commit log for historical reasons
  • Loading branch information
gkc authored Oct 23, 2023
2 parents d880d8b + cd9cff2 commit d79539a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
7 changes: 7 additions & 0 deletions packages/at_secondary_server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 3.0.37
- fix: In the `SyncProgressiveVerbHandler.prepareResponse` method, gracefully
handle any malformed keys which happen to be in the commit log for
historical reasons
- build: Take up at_persistence_secondary_server version 3.0.59 which
includes a similar fix when checking namespace authorization in the
`CommitLogKeyStore._isNamespaceAuthorised` method
## 3.0.36
- fix: Implement notify ephemeral changes - Send notification with value without caching the key on receiver's secondary server
- feat: Implement AtRateLimiter to limit the enrollment requests on a particular connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SyncProgressiveVerbHandler extends AbstractVerbHandler {
@override
bool accept(String command) =>
command.startsWith('${getName(VerbEnum.sync)}:') &&
command.startsWith('sync:from');
command.startsWith('sync:from');

@override
Verb getVerb() {
Expand Down Expand Up @@ -76,11 +76,19 @@ class SyncProgressiveVerbHandler extends AbstractVerbHandler {
enforceNameSpace: false);
if (atKeyType == KeyType.invalidKey) {
logger.warning(
'${commitEntryIterator.current.key} is an invalid key. Skipping from adding it to sync response');
'prepareResponse | ${commitEntryIterator.current.key} is an invalid key. Skipping.');
continue;
}
late AtKey parsedAtKey;
try {
parsedAtKey = AtKey.fromString(commitEntryIterator.current.key!);
} on InvalidSyntaxException catch (_) {
logger.warning(
'prepareResponse | found an invalid key "${commitEntryIterator.current.key!}" in the commit log. Skipping.');
continue;
}
String? keyNamespace =
AtKey.fromString(commitEntryIterator.current.key!).namespace;
parsedAtKey.namespace;
if ((keyNamespace != null && keyNamespace.isNotEmpty) &&
enrolledNamespaces.isNotEmpty &&
(!enrolledNamespaces.containsKey(allNamespaces) &&
Expand All @@ -97,7 +105,7 @@ class SyncProgressiveVerbHandler extends AbstractVerbHandler {
// exist in keystore, skip the key to sync and continue
if (!keyStore.isKeyExists(commitEntryIterator.current.key)) {
logger.finer(
'${commitEntryIterator.current.key} does not exist in the keystore. skipping the key to sync');
'prepareResponse | ${commitEntryIterator.current.key} does not exist in the keystore. Skipping.');
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/at_secondary_server/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_secondary
description: Implementation of secondary server.
version: 3.0.36
version: 3.0.37
repository: https://github.com/atsign-foundation/at_server
homepage: https://www.example.com
publish_to: none
Expand All @@ -25,7 +25,7 @@ dependencies:
at_lookup: 3.0.40
at_server_spec: 3.0.15
at_persistence_spec: 2.0.14
at_persistence_secondary_server: 3.0.58
at_persistence_secondary_server: 3.0.59
intl: ^0.18.1
json_annotation: ^4.8.0
version: 3.0.2
Expand Down

0 comments on commit d79539a

Please sign in to comment.