Status icons: fix AFK-cache crash on secret unit GUIDs#141
Open
Krathe82 wants to merge 1 commit into
Open
Conversation
A unit's GUID can be a SECRET value in 12.0, and a secret cannot be used as a table key — the AFK caches are keyed by GUID (afkStateCache[key] / afkStartTimes[key]), so any unit whose GUID was secret crashed UpdateAFKIcon / ClearAFKCache with "attempted to perform indexed assignment on a table that cannot be indexed with secret keys". GetAFKKey now returns the GUID only when it is accessible (canaccessvalue, checked BEFORE any truthiness test on the GUID) and falls back to the unit token — a plain string, never secret — otherwise. That keeps GUID-based keying (stable across token reassignment) for normal units and a safe key for the rest.
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.
Problem
A unit's GUID can be a secret value in 12.0, and a secret value cannot be used as a table key. The AFK status caches are keyed by GUID (
afkStateCache[key],afkStartTimes[key]), so any unit whose GUID was secret crashedUpdateAFKIcon/ClearAFKCachewith:(reported 13× on live). The code already guarded
canaccessvalueon the AFK/DND results, but never on the cache key itself.Fix
GetAFKKeynow returns the GUID only when it is accessible (canaccessvalue, checked before any truthiness test on the GUID — a secret can't be evaluated in a boolean context) and falls back to the unit token, a plain string that is never secret, otherwise. Every cache read, write, andClearAFKCacheflows throughGetAFKKey, so this one change covers them all. Normal units keep GUID-based keying (stable across unit-token reassignment); the rest get a safe key instead of a crash.