Validate audience platforms before research credit checks

Merged
SI
1mo ago
+233-25

Audience requests currently interpolate an unchecked platform into the research path after the identity/credit gate. Validate it first with a Zod enum derived from the existing platform/source mapping, then reuse the current identity/credit operation for valid requests. Preserve omitted/blank defaults to Instagram and trim supported platform inputs. Unsupported values and path/prototype-key inputs now return400 before research or credit-gate work.

The shared map retains all14existing platform/source pairs byte-for-byte. mapArtistAudienceSource now checks own properties, so toString/constructor/__proto__ no longer resolve to inherited members; unknown internal source names still pass through. Existing provider-neutral id, endpoint billing attribution, successful response formatting and research errors remain unchanged.

This is the current-main successor for API644, exact oldhead1ac58647c92afcaf4f3c9592252049ebdcedcd49, under Mono358. Original six-file patch compared against baseactualcee8d6a0; selected validation/shared-map gaps remained absent. This successor uses current Zod guidance and preserves newer billing attribution. Old PR remains untouched; no bulk triage or held stream/SDK/App work changed.

Validation after current-main refresh:386focused research/artist tests pass across64files; full lint/format/whitespace pass. All seven audience TypeScript files are byte-identical to prior reviewed65e23904. Main adds artist-list comments/verification only; those changes are retained. Originalredproof11failbefore. Prior whole-repository TypeScript had211byte-identical baseline/candidate diagnostics and no additions; this remains historical source evidence. Exact new-head clean CI passes all4requiredchecks,7,112tests/15skips across1,284passingfiles/13skippedfiles, plus response-contract typecheck and preview. Independent exacthead/tree delta review finds no runtime issues; no execution rerun.

Independent prior source review had no runtime findings and one concrete publication companion: maintained Marketing research spec blob39fec6405f2f840ef5054c5df04009920cf3d0c4 promises unmappedplatformpassthrough. Docs is assigned to replace that promise with the unchanged14value enum, trim/default and early400 semantics. Exact artifact: docs-companion-handoff.md/proposal.json in the builder packet. No documentationalignment/publication claim yet.

Current candidate 3c363acdfeee1faa82bf44ad2c37e5da7fa73ac5, tree 2414813611cc630c5bb86f1d801e5806dbb79edd, baseactualmain cee8d6a0cd884df63352ceac50966c20084cd569. This supersedes65e23904 and its CI eligibility. Invalidplatform400 can precede auth as in original644intent; valid requests preserve existinggate. No real customer/provider/database/credit/payment operation, permissions/schema change, credential inspection or manualdeploy. Coordinator/Records retain originalacceptance/qualifyingmerge; no merge/deploymentclaim.

Final currentbasecee8d6a0/head3c363acd/tree24148136 confirmed. Expanded386tests64files and full lint rerunpass. SevenaudienceTSfiles unchanged byrefresh. Publicationcompanion remainsDocs-owned/unverifiedhere; runtime review does not assert publicreferencealignment. No merge/deploymentclaim; coordinator/Records retain qualifyingrelease/originalacceptance.