Skip to content

docs(http): pin the index alignment of FetchObjectsParallel, which looks like a bug - #270

Draft
Denis-hamon wants to merge 1 commit into
ovh:mainfrom
Denis-hamon:fix/fetch-objects-parallel-pads-with-nil
Draft

docs(http): pin the index alignment of FetchObjectsParallel, which looks like a bug#270
Denis-hamon wants to merge 1 commit into
ovh:mainfrom
Denis-hamon:fix/fetch-objects-parallel-pads-with-nil

Conversation

@Denis-hamon

Copy link
Copy Markdown
Contributor

Not a fix — a contract, and a test that defends it

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 to
serve the ~30 call sites.

Measured before changing anything, and the measurement says do not:

  • Seven call sites in internal/services/browser depend 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 details
    to another region's name — silently, and far worse than a hole.
  • None of the 30 call sites 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 of them through
    FetchExpandedArray, which filters. The remaining eight are typed
    []map[string]any, where the hole is a nil slice that range treats 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.

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant