Skip to content

docs: address two follow-up comments from #1902 review - #1977

Merged
bokelley merged 1 commit into
mainfrom
bokelley/post-1902-cleanup
May 24, 2026
Merged

bokelley merged 1 commit into
mainfrom
bokelley/post-1902-cleanup

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Two small follow-up fixes for comments @nastassiafulconis left on #1902 during the 8.0-beta foundation cut.

  1. getAssetSlot JSDoc / behavior mismatch (src/lib/server/decisioning/manifest-helpers.ts). Doc said "Returns `undefined` if the slot is missing or empty" but ![] is falsy in JS, so an empty array slot flows past the guard and returns [] (the filter result on an empty array). Behavior is fine — returning [] for an empty slot matches the "filter result" contract more consistently than collapsing to undefined, and empty arrays are spec-invalid by the minItems: 1 constraint anyway. Updated the JSDoc to reflect what the function actually does, with the empty-array rationale called out.

  2. updatePackageJsonVersion NaN footgun (scripts/sync-version.ts). adcpVersion.split('.').map(Number) produces NaN for prerelease versions like '3.1.0-beta.3' because '0-beta' isn't numeric. Today only [newMajor, newMinor] are destructured so the NaN at index 2 is silently discarded — but the next maintainer to add newPatch would get NaN for every prerelease. Added a one-line comment block making the discarded NaN intentional and pointing at the prerelease-aware regex helper higher in the file.

Empty changeset — docs/comments only, no behavior change.

Test plan

  • CI green (no functional changes)
  • Changeset Check passes (empty changeset committed)

🤖 Generated with Claude Code

Both spotted by @nastassiafulconis during the 8.0-beta foundation cut
and acknowledged at the time; landing now as a small cleanup.

- `getAssetSlot` (`src/lib/server/decisioning/manifest-helpers.ts`):
  JSDoc said "Returns undefined if the slot is missing or empty" but
  `![]` is falsy, so an empty array slot passes the guard and returns
  `[]` from the filter. Behavior is correct — returning `[]` for an
  empty slot is consistent with the filter contract and empty arrays
  are spec-invalid per `minItems: 1` anyway. Updated the JSDoc.

- `updatePackageJsonVersion` (`scripts/sync-version.ts`):
  `adcpVersion.split('.').map(Number)` yields NaN at index 2+ for
  prereleases like `'3.1.0-beta.3'`. Today only [major, minor] are
  destructured so the NaN is intentionally discarded — comment
  added so the next person to add `newPatch` doesn't get bitten.

Empty changeset — docs/comments only, no behavior change.

@aao-ipr-bot aao-ipr-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Both fixes are well-scoped follow-ups that bring the comments back in line with the code.

Things I checked

  • getAssetSlot body at src/lib/server/decisioning/manifest-helpers.ts:71-80. ![] is false (arrays are truthy), so [] flows past the if (!slot) guard and arr.filter(...) returns []. New JSDoc at lines 60-67 matches actual behavior; old JSDoc was misleading.
  • The "missing only" claim is accurate — manifest undefined, assets undefined, or the key absent all hit !slot via optional chaining returning undefined. null slots also return undefined (also !null), but that's a fringe case not worth the prose budget.
  • sync-version.ts:357-368 destructures [major, minor, patch] from the library version and [newMajor, newMinor] from the AdCP version. The NaN warning is on the right line — adding newPatch to the AdCP destructure would silently produce NaN for every prerelease.
  • Empty changeset (.changeset/post-1902-cleanup.md with empty ---\n--- frontmatter) is correct for comment-only changes — satisfies the Changeset Check without bumping a version that doesn't ship behavior.

Minor nits (non-blocking)

  1. Comment example value is off by one NaN. scripts/sync-version.ts:361. '3.1.0-beta.3'.split('.').map(Number) actually produces [3, 1, NaN, 3], not [3, 1, NaN, NaN, 3]. The split on . gives ['3', '1', '0-beta', '3'] — four elements, one NaN. The [..., NaN, NaN, ...] pattern would only appear with two prerelease identifiers like '3.1.0-beta.foo.3'. Spirit of the warning is correct; the worked example isn't. Fix on a follow-up commit if you're touching the file.

Approving.

@bokelley
bokelley merged commit a956161 into main May 24, 2026
11 checks passed
@bokelley
bokelley deleted the bokelley/post-1902-cleanup branch May 24, 2026 12:11
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