Fix undefined array key "port" warning from partial host config in APCu cache - #271
Draft
MelvinBot wants to merge 1 commit into
Draft
Fix undefined array key "port" warning from partial host config in APCu cache#271MelvinBot wants to merge 1 commit into
MelvinBot wants to merge 1 commit into
Conversation
Co-authored-by: Puneet Lath <puneetlath@users.noreply.github.com>
|
@MelvinBot can you merge main into this PR? |
puneetlath
reviewed
Sep 8, 2026
Comment on lines
+677
to
+678
| // A cached entry may be missing its 'port' (e.g. a partial config written by an older worker). Treat | ||
| // it as null so the comparison below detects the mismatch and resets the cache, rather than warning. |
There was a problem hiding this comment.
@MelvinBot can you udpate these comments so each sentence is on its own line. Rather than having the second sentence split by lines.
puneetlath
reviewed
Sep 8, 2026
Comment on lines
+898
to
+900
| // Only update an entry that already exists so we don't auto-vivify a partial host config (one without a | ||
| // 'port') when the cache is cold or was just reset by a concurrent worker. getPossibleHosts will | ||
| // repopulate the cache with full configs on its next call. |
There was a problem hiding this comment.
@MelvinBot can you make this comment more succinct?
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.
Explanation of Change
Fixes a benign-but-noisy
PHP Warning: Undefined array key "port"emitted fromClient::getPossibleHosts().When a Bedrock host connection fails,
markHostAsFailed()did$hostConfigs = apcu_fetch($apcuKey)and then unconditionally wrote$hostConfigs[$host]['blacklistedUntil'] = .... Ifapcu_fetch()returnedfalse(cold cache after a deploy/eviction, or a concurrent worker having just reset it), PHP auto-vivified a host entry containing onlyblacklistedUntiland noport, and stored it back into APCu. A latergetPossibleHosts()iterated the cached configs and read$config['port']unconditionally, tripping the warning.This change makes both sides defensive:
markHostAsFailed()now only updates an entry that already exists (is_array($hostConfigs) && isset($hostConfigs[$host])), so it never writes a partial host config missingport. If the cache is cold,getPossibleHosts()repopulates it with full configs on its next call.getPossibleHosts()reads$config['port'] ?? null, so even a partial entry written by an older worker no longer warns — the null simply forces the existing cache-mismatch reset path.The warning was cosmetic (the originating request completed
200 OK) and self-healing, but it trips BugBot as a staging deploy blocker.Related Issues
https://github.com/Expensify/Expensify/issues/667952
Deployment