Skip to content

Handle commit result when migrating to Harmony#8311

Merged
CrisBarreiro merged 1 commit intodevelopfrom
feature/cris/migrate-harmony-handle-commit-result
Apr 17, 2026
Merged

Handle commit result when migrating to Harmony#8311
CrisBarreiro merged 1 commit intodevelopfrom
feature/cris/migrate-harmony-handle-commit-result

Conversation

@CrisBarreiro
Copy link
Copy Markdown
Collaborator

@CrisBarreiro CrisBarreiro commented Apr 17, 2026

Task/Issue URL: https://app.asana.com/1/137249556945/project/1212227266948491/task/1214127404690655?focus=true

Description

Steps to test this PR

Feature 1

  • [ ]
  • [ ]

UI changes

Before After
!(Upload before screenshot) (Upload after screenshot)

Note

Medium Risk
Touches encrypted SharedPreferences migration and changes error handling/commit semantics; a failure could leave preferences partially migrated or block access to migrated prefs, but behavior is gated behind migration paths with pixel logging.

Overview
Improves encrypted SharedPreferences migration to Harmony by checking the commit() result and surfacing migration failures instead of blindly assuming writes succeeded.

migrateContentsToHarmony now returns a Result and uses a single SharedPreferences.Editor to batch writes, marking MIGRATED_TO_HARMONY only after a successful commit; failures (including unsupported value types) fire the existing migration pixel via a new onMigrationFailure helper and cause the migration callers to return null.

Reviewed by Cursor Bugbot for commit 4e51066. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

editor.putStringSet(key, value.filterIsInstance<String>().toSet())
} else {
logcat(WARN) { "Could not migrate $key from $name preferences" }
return onMigrationFailure(Exception("Could not migrate $key from $name preferences"), name)
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.

@CrisBarreiro checking if it's a deliberate change: previously, encountering a Set of non-Strings (or any other unsupported type) was logged as a warning and migration continued; now it aborts the whole migration and returns Result.failure.

I'm not sure under what circumstances we could end up there (if ever?), but if it happened, would it end up re-attempting the migration over and over?

Copy link
Copy Markdown
Collaborator Author

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'll ever encounter it, at least not now, but I think re-trying the migration over and over and firing a pixel is better than just silently failing. The first case is actionable, the second one is not

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.

SGTM

@CrisBarreiro CrisBarreiro merged commit 19ea805 into develop Apr 17, 2026
23 checks passed
@CrisBarreiro CrisBarreiro deleted the feature/cris/migrate-harmony-handle-commit-result branch April 17, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants