Skip to content

userId: Refactor PPID validation logic with official regex - #15411

Merged
patmmccann merged 3 commits into
prebid:masterfrom
robin-crazygames:patch-1
Jul 29, 2026
Merged

userId: Refactor PPID validation logic with official regex#15411
patmmccann merged 3 commits into
prebid:masterfrom
robin-crazygames:patch-1

Conversation

@robin-crazygames

Copy link
Copy Markdown
Contributor

Updated PPID validation to use regex for length and character checks.

Type of change

  • Bugfix

  • Feature

  • New bidder adapter

  • Updated bidder adapter

  • Code style update (formatting, local variables)

  • Refactoring (no functional changes, no api changes)

  • Build related changes

  • CI related changes

  • Does this change affect user-facing APIs or examples documented on http://prebid.org?

  • Other

Description of change

Google has a regex in the documentation for the format of the PPID that can be send to GAM.
This change uses that regex instead of the length-only check that was present in the code.

Other information

#15385 (related, but doesn't actually fix the issue)

Updated PPID validation to use regex for length and character checks.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d25d3ae15e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread modules/userId/index.ts
Comment on lines +598 to +599
const regex = /^[0-9a-zA-Z+.=/_\-$,{}]{22,150}$/;
if (regex.test(ppidValue)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate the unmodified PPID before returning it

When the selected EID contains a character this new PPID regex permits (for example +, /, _, or =), the value has already been sanitized by replace(/[\W_]/g, '') before this test runs, so valid PPIDs can either be rejected after being shortened or returned to GAM as a different/colliding identifier. Validate the original ID, or stop stripping characters that the regex allows, before passing it to setPublisherProvidedId.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@codex if we stopped stripping characters the regex allows, that would break everyone expecting continuity of these ids

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

  • Preserved historical PPID continuity by continuing to strip non-alphanumeric characters before applying the updated 22–150 character validation. The validator now explicitly reflects the normalized alphanumeric value. modules/userId/index.tsL591-L603
  • Added regression coverage confirming that Google-permitted special characters such as +, /, _, =, and {} are normalized exactly as they were previously. test/spec/modules/userId_spec.jsL1095-L1109
  • Committed the changes on codex-preserve-ppid-normalization with commit 647d670.
  • Created the follow-up PR titled “userId: Preserve PPID normalization continuity.”

Testing

  • npx eslint modules/userId/index.ts test/spec/modules/userId_spec.js --cache --cache-strategy content
  • npx gulp test --nolint --file test/spec/modules/userId_spec.js — 139 affected tests passed in both feature configurations.
  • git diff --check
  • git status --short --branch — working tree clean after commit.

View task →

@barecheck

barecheck Bot commented Jul 29, 2026

Copy link
Copy Markdown

Barecheck - Code coverage report

Total: 96.66%

Your code coverage diff: 0.00% ▴

Uncovered files and lines
FileLines
modules/userId/index.ts173, 207, 221, 233, 293, 344, 741, 751, 762, 768, 787-788, 910-913, 953-954, 1006, 1029, 1036, 1074, 1294, 1313-1314
test/spec/modules/userId_spec.js129, 1000, 1273, 1335

@patmmccann
patmmccann merged commit 0ab1ae0 into prebid:master Jul 29, 2026
99 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants