Skip to content

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

Open
Valpertui wants to merge 1 commit into
developfrom
valpertui/rum-operation-name-validation
Open

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

Conversation

@Valpertui
Copy link
Copy Markdown
Member

What does this PR do?

Validates vital.name client-side in the Feature Operation APIs (startFeatureOperation / succeedFeatureOperation / failFeatureOperation) 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 FO_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 2 times, most recently from f36df5d to 025047d Compare April 23, 2026 18:48
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.
@Valpertui Valpertui force-pushed the valpertui/rum-operation-name-validation branch from 025047d to 16133cc Compare April 23, 2026 19:12
@Suppress(
"UnsafeThirdPartyFunctionCall"
) // Regex is a compile-time constant; matches() cannot throw on a non-null input
val nameMatchesBackendPattern = VALID_OPERATION_NAME_REGEX.matches(name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could instead do:

val nameMatchesBackendPattern = name.matches(VALID_OPERATION_NAME_REGEX)

This way you don't have to suppress the warning, because String.matches is already in detekt_custom_safe_calls.yml.

@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!

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.

3 participants