Skip to content

bugfix: Fix mapping of enums to feature IDs#1538

Merged
jcscottiii merged 1 commit into
mainfrom
jcscottiii/fix-mapping-job
Jun 5, 2025
Merged

bugfix: Fix mapping of enums to feature IDs#1538
jcscottiii merged 1 commit into
mainfrom
jcscottiii/fix-mapping-job

Conversation

@jcscottiii
Copy link
Copy Markdown
Collaborator

@jcscottiii jcscottiii commented Jun 5, 2025

The instructions in the mojom file[1] were updated to reflect how feature developers should translate feature IDs found in the web features repo to enum labels in the mojom file by doing the equivalent of id.title().replace("-", "")

However, our code takes the enum labels and tries to map convert labels to feature IDs.

Unfortunately, there's too much data loss to reliably convert back to the feature ID.

Examples:

  • Case 1: http3 (WebDX ID) -> Http3 (Enum Label) The original ID http3 has no hyphen between the letter 'p' and the digit '3'. A reverse algorithm designed to insert hyphens (e.g., between letters and digits) would incorrectly produce http-3.

  • Case 2: canvas-2d-color-management (WebDX ID) -> Canvas2DColorManagement (Enum Label) Here, the original ID does have hyphens (e.g., canvas-2d). However, the enum label Canvas2DColorManagement provides no explicit signal for these specific hyphens. An algorithm that didn't insert hyphens (to avoid breaking http3) would then fail to restore them.

As a result, we now get all the feature IDs, convert them using the equivalent algorithm in Go into their respective labels and try to use them. There are some labels that have special cases. We handle those as well with a short special cases mapping.

We still have a logging message that the log based metrics check for. That is now emitted two potential places so that string is now a constant variable.

The instructions in the mojom file[1](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/public/mojom/use_counter/metrics/webdx_feature.mojom;l=35-47;drc=822a70f9ac61a75babe9d24ddfc32ab475acc7e1) were updated
to reflect how feature developers should translate feature IDs found in
the web features repo to enum labels in the mojom file by doing the equivalent of `id.title().replace("-", "")`

However, our code takes the enum labels and tries to map convert labels to feature IDs.

Unfortunately, there's too much data loss to reliably convert back to the feature ID.

Examples:

* **Case 1: `http3` (WebDX ID) -> `Http3` (Enum Label)**
    The original ID `http3` has **no hyphen** between the letter 'p' and the digit '3'. A reverse algorithm designed to insert hyphens (e.g., between letters and digits) would incorrectly produce `http-3`.

* **Case 2: `canvas-2d-color-management` (WebDX ID) -> `Canvas2DColorManagement` (Enum Label)**
    Here, the original ID *does* have hyphens (e.g., `canvas-2d`). However, the enum label `Canvas2DColorManagement` provides no explicit signal for these specific hyphens. An algorithm that didn't insert hyphens (to avoid breaking `http3`) would then fail to restore them.

As a result, we now get all the feature IDs, convert them in their
respective labels and try to use them. There are some labels that have special cases.
We handle those as well with a short special cases mapping.
@jcscottiii jcscottiii force-pushed the jcscottiii/fix-mapping-job branch from 2747f0e to a7c60ee Compare June 5, 2025 20:11
@jcscottiii jcscottiii added this pull request to the merge queue Jun 5, 2025
Merged via the queue into main with commit e0650a3 Jun 5, 2025
7 checks passed
@jcscottiii jcscottiii deleted the jcscottiii/fix-mapping-job branch June 5, 2025 23:19
@DanielRyanSmith DanielRyanSmith mentioned this pull request Jun 11, 2025
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.

2 participants