Skip to content

Fix area name comma-split bug in changelog label mapping#2935

Open
lcawl wants to merge 2 commits intomainfrom
tag-fix
Open

Fix area name comma-split bug in changelog label mapping#2935
lcawl wants to merge 2 commits intomainfrom
tag-fix

Conversation

@lcawl
Copy link
Contributor

@lcawl lcawl commented Mar 20, 2026

Fixes #2934

Summary

The MapLabelsToAreas method was splitting area names by comma, which broke area names containing commas (e.g., "Alerting, connectors, and reporting").

Changes

  • Remove comma-splitting logic from PrInfoProcessor.MapLabelsToAreas
  • Remove comma-splitting logic from GitHubReleaseChangelogService.MapLabelsToAreas
  • Update ChangelogConfiguration.cs doc comment to clarify behavior
  • Update changelog.example.yml comments with examples of mapping one label to multiple areas
  • Add unit tests to verify area names with commas are preserved
  • Add integration tests for the multi-area per label pattern

To map one label to multiple areas, repeat the label under each area:

  areas:
    "Search":
      - "Team:Search" "Observability":
      - "Team:Search"

NOTE: Some changes were required on top of the original plan (in #2934) to address the following test failure:

Test fixes

The test expected one GitHub label (Team:Search) listed under two pivot.areas entries to produce both areas.
BuildLabelToAreasMapping used Dictionary<string, string> and did labelToAreas[label] = areaName, so each label could only map to one area—the last area in file order won. That’s why the test failed even after removing the comma split.

The fix is as follows:

  1. BuildLabelToAreasMapping now builds Dictionary<string, List<string>> and appends each area for a label (deduped case-insensitively).
  2. ChangelogConfiguration.LabelToAreas is now
    IReadOnlyDictionary<string, IReadOnlyList<string>>? so each label can map to multiple areas.
  3. MapLabelsToAreas (in PrInfoProcessor and GitHubReleaseChangelogService) iterates every mapped area for each label.
  4. Loader converts the dictionary to IReadOnlyDictionary<string, IReadOnlyList<string>> with labelToAreas?.ToDictionary(...) (also fixes IDE0031).
  5. ChangelogConfigurationTests assert with .ContainSingle().Which where each label still maps to one area.
  6. LabelMappingTests use IReadOnlyList<string> in the MapLabelsToAreas unit test; the multi-area integration test keeps assertions - Search/ - Observability to match emitted YAML (capitalized keys from your config).

dotnet test tests/Elastic.Changelog.Tests now reports 399 passed.

Note: This is a public API change on ChangelogConfiguration: anything that read LabelToAreas[label] as a string must now treat the value as IReadOnlyList<string> (usually one element).

Generative AI disclosure

  1. Did you use a generative AI (GenAI) tool to assist in creating this contribution?
  • Yes
  • No
  1. If you answered "Yes" to the previous question, please specify the tool(s) and model(s) used (e.g., Google Gemini, OpenAI ChatGPT-4, etc.).

Tool(s) and model(s) used: claude-4.5-haiku

The MapLabelsToAreas method was splitting area names by comma, which broke
area names containing commas (e.g., "Alerting, connectors, and reporting").

Changes:
- Remove comma-splitting logic from PrInfoProcessor.MapLabelsToAreas
- Remove comma-splitting logic from GitHubReleaseChangelogService.MapLabelsToAreas
- Update ChangelogConfiguration.cs doc comment to clarify behavior
- Update changelog.example.yml comments with examples of mapping one label to multiple areas
- Add unit tests to verify area names with commas are preserved
- Add integration tests for the multi-area per label pattern

To map one label to multiple areas, repeat the label under each area:
  areas:
    "Search":
      - "Team:Search"
    "Observability":
      - "Team:Search"

Made-with: Cursor
@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 32dc0bf7-bb88-4acd-91a3-98c2805efcaa

📥 Commits

Reviewing files that changed from the base of the PR and between fda645f and 8c77b82.

📒 Files selected for processing (6)
  • src/Elastic.Documentation.Configuration/Changelog/ChangelogConfiguration.cs
  • src/services/Elastic.Changelog/Configuration/ChangelogConfigurationLoader.cs
  • src/services/Elastic.Changelog/Creation/PrInfoProcessor.cs
  • src/services/Elastic.Changelog/GithubRelease/GitHubReleaseChangelogService.cs
  • tests/Elastic.Changelog.Tests/Changelogs/ChangelogConfigurationTests.cs
  • tests/Elastic.Changelog.Tests/Changelogs/Create/LabelMappingTests.cs
✅ Files skipped from review due to trivial changes (1)
  • tests/Elastic.Changelog.Tests/Changelogs/Create/LabelMappingTests.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Elastic.Documentation.Configuration/Changelog/ChangelogConfiguration.cs

📝 Walkthrough

Walkthrough

Updated label→area mapping to stop splitting mapped area names on commas: mapping functions in changelog services now preserve each configured area string as a single entry and iterate explicit lists instead of parsing comma-separated values. The changelog example comment was clarified to state area names may contain commas and that mapping a label to multiple areas requires repeating the label under each area key. Configuration loading and the ChangelogConfiguration.LabelToAreas type were changed to use lists of areas. New unit and integration tests cover the revised behavior.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed PR fully addresses issue #2934: removes comma-splitting from area mapping, changes API to support multi-area-per-label via repeating labels, updates all related implementations and tests.
Out of Scope Changes check ✅ Passed All changes directly address the bug fix objective. Documentation, configuration example, implementation, API, and tests all align with removing comma-splitting and enabling multi-area-per-label mapping.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tag-fix
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can enforce grammar and style rules using `languagetool`.

Configure the reviews.tools.languagetool setting to enable/disable rules and categories. Refer to the LanguageTool Community to learn more.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Elastic.Documentation.Configuration/Changelog/ChangelogConfiguration.cs`:
- Around line 86-90: Change LabelToAreas from a single-string value to a
collection type (e.g. IReadOnlyDictionary<string, IReadOnlyCollection<string>>
or IReadOnlyDictionary<string, IEnumerable<string>>) so a label can map to
multiple areas; update the configuration loader that populates LabelToAreas and
both call sites of MapLabelsToAreas to expect the new collection-valued mapping
and to union/flatten all mapped areas for a label (rather than treating a single
comma-containing string as one area) so the
CreateChangelog_WithOneLabelMappedToMultipleAreas_AddsAllAreas test passes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 23f697cd-a7d3-4582-a5c2-52b99d8453ef

📥 Commits

Reviewing files that changed from the base of the PR and between 1202cd1 and fda645f.

📒 Files selected for processing (5)
  • config/changelog.example.yml
  • src/Elastic.Documentation.Configuration/Changelog/ChangelogConfiguration.cs
  • src/services/Elastic.Changelog/Creation/PrInfoProcessor.cs
  • src/services/Elastic.Changelog/GithubRelease/GitHubReleaseChangelogService.cs
  • tests/Elastic.Changelog.Tests/Changelogs/Create/LabelMappingTests.cs

Comment on lines +392 to +399
foreach (var label in labels)
{
if (!labelToAreasMapping.TryGetValue(label, out var mappedAreas))
continue;

foreach (var area in mappedAreas)
_ = areas.Add(area);
}
Comment on lines +348 to +355
foreach (var label in labels)
{
if (!labelToAreasMapping.TryGetValue(label, out var mappedAreas))
continue;

foreach (var area in mappedAreas)
_ = areas.Add(area);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changelog bug when area names contain commas

1 participant