⚗️ 🐛 validate feature-operation name against schema character set#4525
Open
Valpertui wants to merge 4 commits into
Open
⚗️ 🐛 validate feature-operation name against schema character set#4525Valpertui wants to merge 4 commits into
Valpertui wants to merge 4 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Bundles Sizes Evolution
🚀 CPU PerformancePending... 🧠 Memory Performance
|
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 05ae58d | Docs | Datadog PR Page | Give us feedback! |
The backend enforces [\w.@$-]* on vital.name via the vital-common-schema facet-path rule. The Browser SDK previously had no input validation on feature-operation vitals. Added validation in addOperationStepVital: - blank / whitespace-only name → display.warn, drop event - name with characters outside [\w.@$-]* → display.warn, emit event anyway (backend is source of truth on character-set policy) operation_key is not subject to this rule. Still gated behind the FEATURE_OPERATION_VITAL experimental flag.
cc112c2 to
4ca6f8a
Compare
Co-authored-by: Thomas Lebeau <1926949+thomas-lebeau@users.noreply.github.com>
Co-authored-by: Thomas Lebeau <1926949+thomas-lebeau@users.noreply.github.com>
Co-authored-by: Thomas Lebeau <1926949+thomas-lebeau@users.noreply.github.com>
Member
Author
|
I have read the CLA Document and I hereby sign the CLA |
Member
Author
|
recheck |
thomas-lebeau
approved these changes
May 4, 2026
bcaudan
reviewed
May 4, 2026
|
|
||
| function validateOperationName(name: string): boolean { | ||
| if (typeof name !== 'string' || name.trim().length === 0) { | ||
| display.warn('Feature operation name cannot be empty or blank. Event will not be sent.') |
Collaborator
There was a problem hiding this comment.
💬 suggestion: Similar to what has been done on electron, we should probably display an error if we won't send the event.
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.
Motivation
The authoritative
_vital-common-schema.jsonrestrictsvital.nameto the character set[\w.@$-]*(letters, digits,_,.,@,$,-) and the backend enforces this as a server-side regex on the facet path. The Browser SDK previously had no input validation on feature-operation vitals — blank names, whitespace-only names, and names with disallowed characters were all silently accepted and shipped to intake.This PR brings the Browser SDK in line with the cross-SDK contract shared with iOS, Android, Roku, C++, and Electron
Changes
Adds validation in
addOperationStepVital(inside the existingFEATURE_OPERATION_VITALfeature-flag gate):name→display.warn("Feature operation name cannot be empty or blank. Event will not be sent."), event dropped.[\w.@$-]*→display.warnquoting the exact backend pattern, event still emitted. The backend is the source of truth on the policy, so a client-side drop would force customers to bump the SDK if the rule is ever relaxed.name→ silent emit.operation_keyis not subject to this rule (no schema restriction).JS
\wis always ASCII so no special handling is needed — the non-ASCII test case'ログイン'pins that ASCII-only semantics are retained.Test instructions
The new tests exercise blank-drop, disallowed-character warn+emit (including Unicode and emoji), valid silent emit, and confirm
operation_keywith spaces/slashes still emits silently.Checklist