Skip to content

Enforce schema character set on vital.name in Operation APIs#3393

Open
Valpertui wants to merge 2 commits into
developfrom
valpertui/rum-operation-name-validation
Open

Enforce schema character set on vital.name in Operation APIs#3393
Valpertui wants to merge 2 commits into
developfrom
valpertui/rum-operation-name-validation

Conversation

@Valpertui
Copy link
Copy Markdown
Member

@Valpertui Valpertui commented Apr 23, 2026

What does this PR do?

Validates vital.name client-side in the Operation APIs (startOperation / succeedOperation / failOperation) against the backend's character-set regex [\w.@$-]*.

  • Blank / whitespace-only name → dropped + InternalLogger.Level.WARN
  • Name with characters outside [\w.@$-]*InternalLogger.Level.WARN, event still emitted
  • Valid name → silent emit
  • operationKey has no schema character-set rule and is left untouched

Motivation

The authoritative _vital-common-schema.json documents vital.name as restricted to letters, digits, and - _ . @ $ — it is used as a facet path by the backend. Until now the Android SDK only checked for blank names; non-conforming values (e.g. "user login") were silently shipped to intake, where they are rejected. Client-side validation gives developers immediate feedback at dev time.

Names that fail the character-set regex still emit because the backend is the source of truth on the policy — a client-side drop would force customers to bump the SDK if the server rule is ever relaxed.

Additional Notes

  • New symbols are internal: VALID_OPERATION_NAME_REGEX and OPERATION_ERROR_INVALID_NAME_CHARACTERS. No public API surface changes; api/apiSurface and api/dd-sdk-android-rum.api do not need to be regenerated.
  • java.util.regex.Pattern's default \w is ASCII-only (no UNICODE_CHARACTER_CLASS flag) — the non-ASCII test case "ログイン" pins this behavior against future drift.
  • Part of a cross-SDK rollout (iOS, Browser, Roku, C++, Electron). See the cross-SDK RUM Operations reference spec v1.6 for the shared contract.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@Valpertui Valpertui requested review from a team as code owners April 23, 2026 18:07
Copy link
Copy Markdown

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

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: 3e336d9064

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Valpertui Valpertui force-pushed the valpertui/rum-operation-name-validation branch 3 times, most recently from 025047d to 16133cc Compare April 23, 2026 19:12
@kikoveiga
Copy link
Copy Markdown
Contributor

Please check #3390 and align with that, including using the new startOperation instead and naming functions/variables without the feature word. After that, should be good to go!

@kikoveiga kikoveiga force-pushed the valpertui/rum-operation-name-validation branch 2 times, most recently from 677c18e to cc760e0 Compare June 1, 2026 15:43
@datadog-datadog-prod-us1-2

This comment has been minimized.

@kikoveiga kikoveiga force-pushed the valpertui/rum-operation-name-validation branch from cc760e0 to cfbaf27 Compare June 1, 2026 15:54
@kikoveiga kikoveiga changed the title Enforce schema character set on vital.name in Feature Operation APIs Enforce schema character set on vital.name in Operation APIs Jun 1, 2026
@kikoveiga kikoveiga force-pushed the valpertui/rum-operation-name-validation branch 2 times, most recently from ed09ae6 to d56bd13 Compare June 1, 2026 16:11
@kikoveiga
Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The backend enforces [\w.@$-]* on vital.name via the vital-common-schema
facet-path rule; until now the Android SDK only checked for blank names.
This change validates the character set in featureOperationArgumentsValid:
blank names are dropped with a WARN, names that fail the regex warn but
are still emitted (backend is source of truth on the policy).

operationKey has no schema character-set rule and is left untouched.
Added VALID_OPERATION_NAME_REGEX and FO_ERROR_INVALID_NAME_CHARACTERS
message.
@kikoveiga kikoveiga force-pushed the valpertui/rum-operation-name-validation branch from d56bd13 to 90004e4 Compare June 1, 2026 22:35
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.20%. Comparing base (cafc384) to head (59f3fb2).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3393      +/-   ##
===========================================
+ Coverage    72.18%   72.20%   +0.02%     
===========================================
  Files          964      964              
  Lines        35586    35588       +2     
  Branches      5928     5929       +1     
===========================================
+ Hits         25687    25696       +9     
+ Misses        8278     8277       -1     
+ Partials      1621     1615       -6     
Files with missing lines Coverage Δ
.../android/rum/internal/monitor/DatadogRumMonitor.kt 86.62% <100.00%> (+0.07%) ⬆️

... and 38 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A blank/whitespace-only operationKey is optional metadata, so dropping the whole vital event over it loses a diagnostic data point for good. operationArgumentsValid now warns the developer and still emits, matching the cross-SDK warn-and-emit contract for malformed optional fields. Only a blank name stays a hard drop, since an unnamed step can't be correlated. Reworded OPERATION_ERROR_INVALID_OPERATION_KEY accordingly.

Updated the three blank-key tests to assert the event is still produced alongside the WARN, and added an emoji operation-name test for surrogate-pair coverage.
@Valpertui Valpertui force-pushed the valpertui/rum-operation-name-validation branch from bff5d45 to 59f3fb2 Compare June 2, 2026 16:00
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.

4 participants