Repository navigation
refactor(events): name the event directory from a name the caller hashes - #430
Open
abelonogov-ld wants to merge 1 commit into
Open
abelonogov-ld wants to merge 1 commit into
abelonogov-ld wants to merge 1 commit into
Conversation
…n hashing the mobile key in EventDirectory Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Automated risk review (dry run): Low
This PR would be automatically approved.
Why: This is a small, test-covered refactor that moves event-directory hashing from EventDirectory to LDUtil.hashedStorageName and updates EventStore factories so the on-disk path stays the same. Production callers still hash the mobile key, and new tests pin that hash plus that defaultDirectory does not hash again.
If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.
Sent by Cursor Approval Agent: Dry-Run PR Approver
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


EventDirectory.defaultDirectorynow takes a name that is already hashed and uses it as it is. The hashing moves out toLDUtil.hashedStorageName(mobileKey), which theEventStorefactories call. This follows the review on iOS (ios-client-sdk#538), whereEventDirectory.defaultUrlnow takes an already hashed name in the same way.Stacked on #408 (tier 3).
hashedStorageNameis the samehexDigest(mobileKey, 16)thatEventDirectoryused privately, so events stored by tier 3 are found where they were.EventDirectoryno longer knows about mobile keys. It places a store undernoBackupFilesDir/com.launchdarkly.events/<name>, and whoever supplies the name decides how it is hashed.EventStorageLocationcallsEventDirectory.defaultDirectory(noBackupFilesDir, mobileKey), which would still compile after this change but would point at a directory named for the raw key. Whichever of the two merges second should callLDUtil.hashedStorageName(mobileKey)there.Tests:
LDUtilTestpinshashedStorageName("mob-12345")to3a4f14b3feba38b362ad80b504238faaand checks that it does not hold the key.EventStoreTestchecks thatdefaultDirectoryuses the name it is given without hashing it again.DirectEventProcessorTestbuilds the directory through oneenvironmentDirectory()helper instead of five copies of the call../gradlew :launchdarkly-android-client-sdk:testDebugUnitTest: 1259 tests, 0 failures (25 skipped).Note
Overview
Event persistence paths are unchanged on disk, but who hashes the mobile key moved:
EventDirectory.defaultDirectorynow takes anenvironmentNameand uses it verbatim undercom.launchdarkly.events/, instead of hashing the mobile key insideEventDirectory.EventStorefactory methods now callLDUtil.hashedStorageName(mobileKey)(16-byte SHA-256 hex, same as before) before resolving the directory.EventDirectoryno longer depends on mobile keys.Tests add coverage for
hashedStorageNameand fordefaultDirectorynot re-hashing; integration tests use a sharedenvironmentDirectory()helper.Reviewed by Cursor Bugbot for commit 98abe4b. Bugbot is set up for automated code reviews on this repo. Configure here.