Repository navigation
docs: address two follow-up comments from #1902 review - #1977
Merged
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
LGTM. Both fixes are well-scoped follow-ups that bring the comments back in line with the code.
Things I checked
getAssetSlotbody atsrc/lib/server/decisioning/manifest-helpers.ts:71-80.![]isfalse(arrays are truthy), so[]flows past theif (!slot)guard andarr.filter(...)returns[]. New JSDoc at lines 60-67 matches actual behavior; old JSDoc was misleading.- The "missing only" claim is accurate —
manifestundefined,assetsundefined, or the key absent all hit!slotvia optional chaining returningundefined.nullslots also returnundefined(also!null), but that's a fringe case not worth the prose budget. sync-version.ts:357-368destructures[major, minor, patch]from the library version and[newMajor, newMinor]from the AdCP version. The NaN warning is on the right line — addingnewPatchto the AdCP destructure would silently produceNaNfor every prerelease.- Empty changeset (
.changeset/post-1902-cleanup.mdwith 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)
- 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.
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.
Summary
Two small follow-up fixes for comments @nastassiafulconis left on #1902 during the 8.0-beta foundation cut.
getAssetSlotJSDoc / 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 toundefined, and empty arrays are spec-invalid by theminItems: 1constraint anyway. Updated the JSDoc to reflect what the function actually does, with the empty-array rationale called out.updatePackageJsonVersionNaN footgun (scripts/sync-version.ts).adcpVersion.split('.').map(Number)producesNaNfor 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 addnewPatchwould getNaNfor 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
🤖 Generated with Claude Code