docs(http): pin the index alignment of FetchObjectsParallel, which looks like a bug - #270
Draft
Denis-hamon wants to merge 1 commit into
Draft
Conversation
…oks like a bug
The result of FetchObjectsParallel is index-aligned with its ids, and stays
aligned when ignoreErrors is set: an id whose fetch failed keeps its slot,
holding the zero value of T. A slice with nil holes in it reads like an
oversight, so this was queued as a defect to fix in the helper — one change for
the ~30 call sites that share it.
Measured before changing anything, and the measurement says do not:
- Seven call sites in internal/services/browser pair objects[i] with a name
held in a parallel slice (allNames[i], allRegionNames[i]). Compacting the
result would attach one region's details to another region's name — silently,
and far worse than a hole.
- Of the 30 call sites, none is actually broken by the padding. Two pass
ignoreErrors false, so a failure returns an error and no holes exist. Twenty
pass true and skip nil explicitly, several through FetchExpandedArray, which
filters. The remaining eight are typed []map[string]any, where the hole is a
nil slice that ranges as empty.
So the contract is documented where it lives, and a test pins it: it fails if
anyone makes the result dense. Verified in both directions — the test passes as
is and fails against a compacting version of the helper, which is the change this
comment exists to prevent.
Signed-off-by: Denis Hamon <denis.hamon@ovhcloud.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Not a fix — a contract, and a test that defends it
The result of
FetchObjectsParallelis index-aligned with itsids, andstays aligned when
ignoreErrorsis set: an id whose fetch failed keeps itsslot, holding the zero value of
T. A slice withnilholes in it reads like anoversight, so this was queued as a defect to fix in the helper — one change to
serve the ~30 call sites.
Measured before changing anything, and the measurement says do not:
internal/services/browserdepend on the alignment.They pair
objects[i]with a name held in a parallel slice (allNames[i],allRegionNames[i]). Compacting the result would attach one region's detailsto another region's name — silently, and far worse than a hole.
ignoreErrorsfalse, so a failure returns an error and no holes exist. Twentypass true and skip
nilexplicitly, several of them throughFetchExpandedArray, which filters. The remaining eight are typed[]map[string]any, where the hole is a nil slice thatrangetreats as empty.So the contract is documented where it lives, and one test pins it. Verified in
both directions: it passes as is, and fails against a compacting version of the
helper — which is the change this comment exists to prevent.