You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Walkthrough
The change adds runWithTransientProfile to the Eco API and delegates it to ProfileHandler. The handler tracks transient uses and releases offline profiles when no uses or pending writes remain. PersistentDataHandler tracks unfinished writes by UUID, and ProfileWriter reports queued writes by UUID. The change also adds forEachSavedPlayer, which runs an action for each saved player with its transient profile. A test checks pending-write status before and after a scheduled save.
Priority: Low
Merge Risk: Moderate · up to 1303f
An online player’s resolved profile can be evicted while still in use, causing duplicate or divergent profile state. Correct the ownership-aware release check before merging.
Security architecture risk: Moderate · up to 1303f
Custom player-to-profile mappings can cause bulk operations to use the wrong identity or release data still used by online players. Failed saves can also become visible as older values after release. These are conditional state-integrity risks; direct exploitation by an untrusted player has not been established.
Retained concerns
Medium · reliability · inferred: Release protects a profile only when its own UUID is online or transiently held. If online player A resolves to offline storage UUID B, a transient operation for B can evict A's profile after writes drain, because the owner-to-profile mapping is not consulted. Conversely, an action held under A can load B without retaining or releasing B. Automatic action-completion eviction is new; it can break shared-profile ownership and leave callers holding independently mutable profile instances.
Medium · architecture · inferred: The new saved-player operation constructs OfflinePlayer objects from saved storage UUIDs. The existing resolver contract explicitly permits player identity and storage identity to differ. Consequently, bulk reset or migration callbacks can receive synthetic player identities and resolve those storage UUIDs again, potentially targeting different data rather than the profiles enumerated. Identity resolution is compatible; the concern requires a custom resolver.
Medium · reliability · inferred: Release treats empty pending and in-flight sets as permission to evict, but those sets also clear after failed writes. The writer drops failed submissions, and asynchronous handler writes clear their marker in finally even when serialization fails. A transient action's updated cached value can therefore be discarded and a later load return older persisted state. Failure-dropping existed before this PR; the new eviction consumer materially changes failure containment and visibility of unsuccessful bulk updates.
Security review details
Security Blast Radius
inferred — A bulk callback can affect the entire saved-profile population returned by the configured default store. Resolver-selected targets may differ from that population, and writes route to local or default storage according to key configuration. Actual exposure depends on installed callers and resolver policy, not merely on a single player's session.
Security Findings and Attack Paths
inferred — The supported concerns are conditional identity and state-integrity failures. Wrong-target bulk updates require a non-identity resolver; stale reloads require failed persistence followed by release. The inspected paths do not establish an untrusted-player entrypoint, privilege escalation, or a security-sensitive key affected by those conditions.
Trust Boundaries and Controls
observed — The changed entrypoints accept installed-plugin callbacks and UUIDs, delegating into existing profile and persistence APIs. Their controls are lifecycle guards, not authorization checks: direct online-UUID retention, transient-use counts, queued-write tracking, and in-flight handler tracking.
Resilience and Maintainability Implications
inferred — The release decision crosses queue and asynchronous-handler state but has no successful-persistence outcome to consult. This weakens containment of failed updates: task completion can authorize eviction even when durable data remains unchanged.
Hardening Proposals
proposed — Separate player enumeration from storage-profile enumeration, bind transient retention to the actual resolved profile and its active owners, and distinguish failed persistence from successful completion before permitting eviction.
Pre-merge checks: 2 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 2 passed
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 7 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Files skipped from review as they are similar to previous changes: 1
jvm-lint-baseline.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Major · Keep resolved profiles while their owner is online. · ProfileHandler.kt:139-140
eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/profiles/ProfileHandler.kt:139-140 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Keep resolved profiles while their owner is online.
EcoImpl allows a custom PlayerProfileResolver to map an online player to another UUID. forEachSavedPlayer passes saved profile UUIDs to runWithTransientProfile. If that UUID differs from the online player's UUID, Bukkit.getPlayer(uuid) returns null, so releaseProfile can remove the resolved profile from loaded. A later access can create a second profile object and split cached state.
Track the owner UUID with each resolved profile and retain the profile while that owner is online. Keep unloadPlayer responsible for removing the resolved profile after the owner leaves.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 06f3f519-2202-41e3-8654-f547e5154232
Commits
Reviewing files that changed from the base of the PR and between 0a8030e and 42134e3.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Keep resolved profiles referenced by an online player. · ProfileHandler.kt:139-140
eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/profiles/ProfileHandler.kt:139-140 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Keep resolved profiles referenced by an online player.
When a resolver maps online player A to offline UUID B, forEachSavedPlayer can call runWithTransientProfile(B). releaseProfile(B) checks only whether B is online, so it can remove loaded[B] while A still holds that profile. A later PlayerProfile.load(A) then creates a second EcoPlayerProfile for B. Each object has its own cached data, so reads and writes can diverge.
Check the resolved-profile owners before removing a profile.
Suggested fix
private fun releaseProfile(uuid: UUID) {
- if (Bukkit.getPlayer(uuid) != null) {+ if (+ Bukkit.getPlayer(uuid) != null ||+ resolvedProfiles.any { (owner, profiles) ->+ Bukkit.getPlayer(owner) != null && uuid in profiles+ }+ ) {
return
}
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 702a41f9-03bc-490a-9755-5a93ee4dcded
Commits
Reviewing files that changed from the base of the PR and between 42134e3 and c172979.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
echo'--- PlayerbaseOperations.kt 70-120 ---'
sed -n '70,120p' eco-api/src/main/kotlin/com/willfp/eco/core/data/PlayerbaseOperations.kt
echo'--- ProfileHandler.kt 365-385 ---'
sed -n '365,385p' eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/profiles/ProfileHandler.kt
echo'--- ProfileHandler.kt 440-460 ---'
sed -n '440,460p' eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/profiles/ProfileHandler.kt
Repository: Auxilor/eco
Length of output: 3109
Serialise write() with flush() so a pending key cannot be left behind.
write() adds the value to valuesToWrite and then adds the key to pendingKeys in two separate steps. flush() is @Synchronized, but write() is not, so the two can interleave. write() can run on an async thread. forEachSavedPlayer runs its action off the main thread, and that action can write to player.profile.
If flush() runs between those two steps, it can commit and remove the new value before pendingKeys records the key. The key then stays in pendingKeys with no queued value. hasPending(uuid) returns true. Only a later write and flush of that same key clears it.
releaseProfile() reschedules itself while hasPending(uuid) is true, and it has no retry limit. For an offline player, that loop can run indefinitely, so the profile is never released.
Making write() synchronised on the same monitor as flush() removes this interleaving. Both updates then happen as one step relative to a flush.
The reason will be displayed to describe this comment to others. Learn more.
Fixed: write() now puts the value inside pendingKeys.compute for the uuid. The cleanup in flush() runs in computeIfPresent on the same uuid, so it sees the value and the key together and cannot leave a key without a value. write() is not synchronised with flush(), because write() runs inside the profile map's compute and flush() calls listeners, so a shared monitor could deadlock.
The reason will be displayed to describe this comment to others. Learn more.
@Exanthiax The supplied code fixes the reported race. write() now updates both maps inside pendingKeys.compute. The cleanup in flush() uses computeIfPresent for the same UUID, so it cannot run between those updates and leave a stale pending key.
The shared @Synchronized monitor I suggested is not needed for this fix. Your approach also avoids adding that monitor to the profile-map lock path.
The reason will be displayed to describe this comment to others. Learn more.
@Exanthiax The supplied code fixes the reported race. write() now updates both maps inside pendingKeys.compute. The cleanup in flush() uses computeIfPresent for the same UUID, so it cannot run between those updates and leave a stale pending key.
The shared @Synchronized monitor I suggested is not needed for this fix. Your approach also avoids adding that monitor to the profile-map lock path.
@ExanthiaxThe reported code issues are addressed, but GitHub still reports the PR as blocked from merging.
I checked the current head, 1303fa5:
All four reported build and lint checks passed.
GitHub reports no merge conflicts.
All other review threads are resolved.
This thread is still open, despite my earlier message saying it was resolved. That statement was incorrect.
The supplied code fixes this thread’s pending-key race. I have no remaining objection from this finding.
Before merging, check the PR’s merge box for the remaining branch-protection requirements. The API reports BLOCKED but does not identify the reason. The saved docstring-coverage failure is warning-only, not a blocking gate.
This is a merge recommendation for the reviewed findings, not a formal PR approval. Automatic approval is disabled.
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
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.
Child PRs: