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

fix: at_commons 4.0.0 uptake in at_Client #1192

Merged
merged 17 commits into from
Jan 16, 2024
Merged

Conversation

purnimavenkatasubbu
Copy link
Member

@purnimavenkatasubbu purnimavenkatasubbu commented Jan 4, 2024

- What I did
Updated the following dependencies

  • at_commons to v4.0.0
  • at_utils to v3.0.16
  • at_lookup to v3.0.44
  • at_chops to v1.0.7
  • at_persistence_secondary_server to v3.0.60

Also made updates as per the at_commons:4.0.0 changes

Updated the melos.yaml temporarily to avoid at_client being picked from the path. This causes "dart run melos bootstrap" to fail because at_client_mobile is compatible with at_commons-4.0.0 while at_client is upgraded to 4.0.0. This does not affect the mobile apps. Once the at_client_mobile is compatible with at_commons-4.0.0 will revert the change.

- How to verify it
All the unit, functional, and end2end tests should pass
All the apps should work fine

- Description for the changelog

@sitaram-kalluri sitaram-kalluri requested review from sitaram-kalluri, gkc and murali-shris and removed request for sitaram-kalluri January 8, 2024 06:40
@sitaram-kalluri sitaram-kalluri marked this pull request as ready for review January 8, 2024 11:33
Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

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

This PR has a lot of files changed

Via the "Files Changed" tab), please add a brief explanation of the reason for each change (at least the first time it appears - e.g. the change from atKey.key ?? '' to atKey.key appears in many place - please explain why.)

Please also consider for every change here whether it is a breaking change for the at_client package

@@ -41,7 +41,7 @@ class AtCollectionMethodImpl {
_logger.finest('Self key to be used : $atKey');
var atOperationItemStatus = AtOperationItemStatus(
atSign: atKey.sharedBy ?? '',
key: atKey.key ?? '',
key: atKey.key,
Copy link
Member

Choose a reason for hiding this comment

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

Earlier, the AtKey.key is a nullable variable, but the named argument "key" does not accept NULL value. Hence defaulted to empty string in case of null. In at_commons-4.0.0, the AtKey.key is prefixed with late and "?" (which denotes that variable can be null) is removed because key can never be null in AtKey,

..metadata!.ccd = objectLifeCycleOptions?.cascadeDelete ?? true
..metadata!.ttl = objectLifeCycleOptions?.timeToLive?.inMilliseconds
..metadata!.ttb = objectLifeCycleOptions?.timeToBirth?.inMilliseconds
..metadata.ccd = objectLifeCycleOptions?.cascadeDelete ?? true
Copy link
Member

Choose a reason for hiding this comment

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

In at_commons-> AtKey, updated the "metadata" field from nullable field (removed "?"). With the change, the field is defaulted to Metadata instance - "Metadata metadata = Metadata();"

..sharedWith = atKey.sharedWith
..atKey = keyWithNamespace
..sharedBy = atKey.sharedBy;
var builder = DeleteVerbBuilder()..atKey = atKey;
Copy link
Member

Choose a reason for hiding this comment

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

The fields of AtKey are now substituted with AtKey instances in all verb builders. The atKey object is directly assigned, and the code responsible for assigning fields of atKey has been removed

@@ -470,7 +451,7 @@ class AtClientImpl implements AtClient, AtSignChangeListener {

@visibleForTesting
ensureLowerCase(AtKey atKey) {
if ((atKey.key != null && upperCaseRegex.hasMatch(atKey.key!)) ||
if (upperCaseRegex.hasMatch(atKey.key) ||
Copy link
Member

Choose a reason for hiding this comment

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

Since Atkey.key is modified as a non null variable in at_commons, removed the non-null assertion operator

@@ -487,12 +468,12 @@ class AtClientImpl implements AtClient, AtSignChangeListener {
if (atKey.sharedBy.isNull) {
atKey.sharedBy = _atSign;
}
if (atKey.metadata!.namespaceAware) {
if (atKey.metadata.namespaceAware) {
Copy link
Member

Choose a reason for hiding this comment

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

Since Atkey.metadata is modified as a non null variable (defaulted to "Metadata()"), removed the non-null assertion operator

..isBinary = metadata.isBinary
..isEncrypted = metadata.isEncrypted
..dataSignature = metadata.dataSignature
..atKey = atKey
Copy link
Member

Choose a reason for hiding this comment

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

The fields of AtKey are now substituted with AtKey instances in all verb builders. The atKey object is directly assigned, and the code responsible for assigning fields of atKey has been removed

..operation = AtConstants.updateMeta;

var updateMetaResult = await getSecondary()
.executeVerb(builder, sync: SyncUtil.shouldSync(updateKey!));
.executeVerb(builder, sync: SyncUtil.shouldSync(updateKey));
Copy link
Member

Choose a reason for hiding this comment

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

Since Atkey.key is modified as a non null variable in at_commons, removed the non-null assertion operator

@@ -949,7 +920,7 @@ class AtClientImpl implements AtClient, AtSignChangeListener {
PriorityEnum? priority,
StrategyEnum? strategy,
int? latestN,
String? notifier = SYSTEM,
String? notifier = AtConstants.system,
Copy link
Member

Choose a reason for hiding this comment

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

Replaced the use of legacy at_constants (which are now removed from at_commons -4.0.0) with new references to new AtConstants file

(atKey.metadata != null &&
atKey.metadata!.isPublic! &&
!atKey.metadata!.isCached)) {
(atKey.metadata.isPublic && !atKey.metadata.isCached)) {
Copy link
Member

Choose a reason for hiding this comment

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

Since AtKey.metadata is not null and boolean fields in Metadata have default values instead of null, removed the null check and non null assertion operator

(metaData[CCD].toLowerCase() == 'true')
? builder.ccd = true
: builder.ccd = false;
if (metaData[AtConstants.ttl] != null)
Copy link
Member

Choose a reason for hiding this comment

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

The AT_TTL, AT_TTB, AT_TTR...which is are a part of "at_constants_legacy.dart" which is deprecated and removed in at_commons-4.0.0. The "at_constants_legacy.dart" is replaced with "at_constants.dart" in at_commons.

@@ -12,8 +12,6 @@ class GetRequestTransformer implements RequestTransformer<AtKey, VerbBuilder> {

@override
VerbBuilder transform(AtKey atKey, {RequestOptions? requestOptions}) {
// Set the default metadata if not already set.
atKey.metadata ??= Metadata();
Copy link
Member

Choose a reason for hiding this comment

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

Since AtKey.metadata is defaulted to "Metadata()". Hence removed the above line.

@@ -21,8 +21,6 @@ class NotificationRequestTransformer
@override
Future<NotifyVerbBuilder> transform(
NotificationParams notificationParams) async {
// If metadata is not set, initialize Metadata instance.
notificationParams.atKey.metadata ??= Metadata();
Copy link
Member

Choose a reason for hiding this comment

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

Since AtKey.metadata is defaulted to "Metadata()". Hence removed the above line.

builder.ivNonce = notificationParams.atKey.metadata?.ivNonce;
builder.skeEncKeyName = notificationParams.atKey.metadata?.skeEncKeyName;
builder.skeEncAlgo = notificationParams.atKey.metadata?.skeEncAlgo;
builder.atKey.metadata.ttl = notificationParams.atKey.metadata.ttl;
Copy link
Member

Choose a reason for hiding this comment

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

The fields of AtKey and Metadata are now substituted with AtKey instances in all verb builders. The metadata values are assigned to the metadata fields in the atKey.metadata.

if (tuple.one.metadata != null &&
tuple.one.metadata!.isBinary != null &&
tuple.one.metadata!.isBinary!) {
if (tuple.one.metadata.isBinary) {
Copy link
Member

Choose a reason for hiding this comment

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

Since in AtKey.metadata is defaulted to "Metadata()" and boolean fields in metadata have default values, removed null check.

..sharedBy = atNotification.from
..metadata = atNotification.metadata;
..sharedBy = atNotification.from;
if (atNotification.metadata != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Since AtKey.metadata does not hold null value, added a null check before assigning the metadata.

@sitaram-kalluri sitaram-kalluri requested a review from gkc January 9, 2024 07:44
@sitaram-kalluri
Copy link
Member

This PR has a lot of files changed

Via the "Files Changed" tab), please add a brief explanation of the reason for each change (at least the first time it appears - e.g. the change from atKey.key ?? '' to atKey.key appears in many place - please explain why.)

Please also consider for every change here whether it is a breaking change for the at_client package

@gkc: Added comments explaining the changes. We have ensured not to introduce any breaking changes. @purnimavenkatasubbu has completed a round of testing with mobile apps with this branch and no bugs are reported.

atKey.metadata ??= Metadata();
String keyWithNamespace;
if (atKey.metadata!.namespaceAware) {
keyWithNamespace = AtClientUtil.getKeyWithNameSpace(atKey, _preference!);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the namespace fixing no longer required?

Copy link
Member

Choose a reason for hiding this comment

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

By assigning atKey directly to the verb builder, key construction utilizes AtKey.toString(), appending the namespace to the key. For the key we do not want namespace to be appended, leaving the namespace fields unset or initializing them to an empty string will suffice.

However, when the user doesn't set a namespace for the AtKey, the earlier practice involved appending the namespace from the AtClientPreferences when namespaceAware is set to "true" is missing here. Will add the code where if atKey.namespace is null or empty and namespaceAware is true, then set the namespace from AtClientPreference.namespace

..isBinary =
(atKey.metadata?.isBinary != null) ? atKey.metadata?.isBinary! : false
..isLocal = atKey.isLocal;
..atKey = (AtKey()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you creating a new atKey object here? Can't we just use the one that was passed as a method parameter?

Copy link
Member

Choose a reason for hiding this comment

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

The AtKey received from the put method is assigned to the UpdateVerbBuilder.atKey. Removed the above because we not have assign each field of atKey to the atKey in UpdateVerbBuilder.

Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

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

A few more requests and comments

@gkc
Copy link
Contributor

gkc commented Jan 9, 2024

This PR has a lot of files changed
Via the "Files Changed" tab), please add a brief explanation of the reason for each change (at least the first time it appears - e.g. the change from atKey.key ?? '' to atKey.key appears in many place - please explain why.)
Please also consider for every change here whether it is a breaking change for the at_client package

@gkc: Added comments explaining the changes. We have ensured not to introduce any breaking changes. @purnimavenkatasubbu has completed a round of testing with mobile apps with this branch and no bugs are reported.

Thank you both

@sitaram-kalluri sitaram-kalluri requested a review from gkc January 11, 2024 10:22
Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

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

@sitaram-kalluri @purnimavenkatasubbu Please can you do another round of testing of atmospherePro, atBuzz and at_talk with this branch, just to make sure

@sitaram-kalluri
Copy link
Member

@sitaram-kalluri @purnimavenkatasubbu Please can you do another round of testing of atmospherePro, atBuzz and at_talk with this branch, just to make sure

@gkc : Sure, will do a round of testing with apps and keep you updated.

@purnimavenkatasubbu
Copy link
Member Author

I did a quick round of sanity testing with atMospherePro, atBuzz, and atTalk pointing to this branch of at_client. It looks good. Attaching below POTs
atBuzzLogsUpdateAtClientDependencies12th.txt
[atmospherePRoUpdateAtClientDependencies12Jan.txt](https://github.com/atsign-foundation/at_client_sdk/files/13922366/atmospherePRoUpda
Screenshot from 2024-01-12 23-01-14
Screenshot from 2024-01-12 23-01-23
teAtClientDependencies12Jan.txt)

gkc
gkc previously approved these changes Jan 13, 2024
@gkc gkc merged commit 4d67c5b into trunk Jan 16, 2024
8 checks passed
@gkc gkc deleted the update_atclient_dependencies branch January 16, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants