Skip to content

feat: null-safe creator list envelope consistency check - #291

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
boys-cyberhub:feat/issue-281
May 27, 2026
Merged

feat: null-safe creator list envelope consistency check#291
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
boys-cyberhub:feat/issue-281

Conversation

@boys-cyberhub

Copy link
Copy Markdown
Contributor

What changed

  • Added normalizeCreatorListItems() helper in creators.serializers.ts that coerces null | undefined profiles to [] before mapping, so the items field is always an array.
  • Updated serializeCreatorList() signature to accept CreatorProfile[] | null | undefined.
  • Updated wrapPublicCreatorListResponse() in public-creator-list-envelope.utils.ts to coerce null | undefined items to [] at the envelope level (defence-in-depth).
  • Added jest.setup.ts + wired setupFiles in jest.config.js so Jest can load modules that transitively import src/config.ts without requiring real env vars.
  • Extended creator-feed-empty-filters.integration.test.ts with 3 tests asserting items is always an array when the data layer returns null or undefined.
  • Fixed a pre-existing assertion bug in the same file: objectContaining({ verified: undefined }) incorrectly assumed Zod emits optional absent keys with undefined; corrected to check key absence instead.
  • Fixed missing res.set mock in makeRes() which caused attachTimestampHeader to throw, silently swallowing all responses.

Why

Creator list endpoints may return null instead of an empty array in edge cases, breaking any client-side iteration that calls .map() or .forEach() on items without a null guard.

How to test

pnpm exec jest --testPathPatterns "creator-feed-empty-filters"
# → Tests: 29 passed

Closes #281

@Chucks1093
Chucks1093 merged commit 23dc60a into accesslayerorg:main May 27, 2026
1 check passed
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.

Add response envelope consistency check for empty list vs null list

2 participants