Skip to content

Treat non-US reverse DNS prefixes as category roots - #8697

Merged
jkschneider merged 2 commits into
mainfrom
tim/root-category-tld-prefixes
Sep 26, 2026
Merged

jkschneider merged 2 commits into
mainfrom
tim/root-category-tld-prefixes

Conversation

@timtebeek

Copy link
Copy Markdown
Member

Symptom

A customer publishing a recipe library under a non-US reverse DNS prefix shows up in the marketplace nested under a meaningless top-level segment. uk.co.acme.recipes renders as Uk > Co > Acme > Recipes; de.example.recipes renders as De > Example > Recipes.

This happens because a package segment with no matching category descriptor gets a synthetic category built from its capitalized name. com, org, io, ai, tech and software already have root: true descriptors in core-categories.yml — everything else does not.

Fix

Add root: true category descriptors to rewrite-core/src/main/resources/META-INF/rewrite/core-categories.yml. A root descriptor is not rendered as a node and its children are hoisted, which is enforced in CategoryTree.getCategories() and in YamlRecipeBundleReader.inferCategoriesFromName().

Generic TLDs:

net edu gov mil int dev app cloud us eu

Country code TLDs:

uk de nl fr ch at be dk se no fi ie es it pl cz au nz ca jp cn in kr sg hk br mx za il ae

Second level domains, rooted in addition to their parent — without these, dropping "Uk" only promotes "Co" to the top level:

uk.co uk.org uk.ac uk.gov uk.me jp.co jp.ne jp.or au.com au.net au.org br.com za.co nz.co il.co in.co kr.co

Matching is anchored at the full partial package (uk.co, not any segment named co), so short entries that are also English words are only ever consumed in first position. Nothing that could plausibly be a category in its own right is rooted.

no is quoted, since YAML 1.1 would otherwise resolve it to a boolean.

Tests

  • CategoryTreeTest#reverseDnsPrefixesAreCategoryRoots — uk.co.acme and de.example are top-level categories; uk, uk.co and de are not.
  • YamlRecipeBundleReaderTest#twoSegmentReverseDnsPrefixesAreOmittedFromTheInferredPath — uk.co.acme.recipes.FindAndReplace infers Acme > Recipes.
  • YamlRecipeBundleReaderTest#singleSegmentReverseDnsPrefixesAreOmittedFromTheInferredPath — de.example.recipes.SomeRecipe infers Example > Recipes.

All three fail against the current core-categories.yml and pass with it.

A recipe library published under, say, `uk.co.acme.recipes` had no matching
category descriptor for `uk`, so the marketplace synthesized one and rendered
the library under a meaningless "Uk" > "Co" > "Acme" path. Marking these
prefixes as roots drops them from the displayed path, both in `CategoryTree`
and in the category inference `YamlRecipeBundleReader` does from a recipe name.

Second level domains (`uk.co`, `jp.co`, `au.com`, ...) are rooted alongside
their parent, otherwise dropping "Uk" only promotes "Co" to the top level.
Matching is anchored at the full partial package, so a segment named `co`
deeper in a package is unaffected.
@timtebeek

Copy link
Copy Markdown
Member Author
   FAIL  test/javascript/templating/control-parentheses-capture.test.ts > a capture that is a whole ControlParentheses > with expression
  AssertionError: expected undefined to be defined
   ❯ findFirst test/javascript/templating/control-parentheses-capture.test.ts:46:19
       44|     };
       45|     await visitor.visit(cu, new ExecutionContext());
       46|     expect(found).toBeDefined();
         |                   ^
       47|     return found!;
       48| }
   ❯ matchFirst test/javascript/templating/control-parentheses-capture.test.ts:52:28
   ❯ test/javascript/templating/control-parentheses-capture.test.ts:85:16

@MBoegers
MBoegers requested review from MBoegers and a lite review from Copilot and removed request for Copilot September 9, 2026 09:30

@MBoegers MBoegers left a comment

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.

LGTM fixing CI and than I'll merge

@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Sep 9, 2026
@timtebeek

Copy link
Copy Markdown
Member Author

Did you find anything that made you hold off on a merge @MBoegers ? If not feel free to merge when you read this.

@timtebeek

Copy link
Copy Markdown
Member Author

As discussed: this is ready to go out, but as a core change it needs review before a merge.

@timtebeek timtebeek added the enhancement New feature or request label Sep 25, 2026
@jkschneider
jkschneider merged commit 41a104a into main Sep 26, 2026
1 check passed
@jkschneider
jkschneider deleted the tim/root-category-tld-prefixes branch September 26, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants