Replace changelog sanitize_private_links with link_allow_repos#3029
Replace changelog sanitize_private_links with link_allow_repos#3029
Conversation
📝 WalkthroughWalkthroughThis PR replaces the boolean Sequence DiagramsequenceDiagram
actor User as User/CLI
participant Config as Configuration Loader
participant Bundler as Bundling Service
participant Sanitizer as LinkAllowlistSanitizer
participant Output as Bundle Output
User->>Config: Load changelog.yml with link_allow_repos
Config->>Config: Validate bundle.repo (no + syntax) and allowlist entries (owner/repo)
Config-->>Bundler: Return validated BundleConfiguration
Bundler->>Bundler: Ensure bundle is resolved when applying allowlist
alt link_allow_repos present
Bundler->>Sanitizer: TryApplyBundle(bundle, allowlist, defaults)
Sanitizer->>Sanitizer: For each PR/issue, parse resolved owner/repo
Sanitizer->>Sanitizer: Compare against allowlist
alt In allowlist
Sanitizer->>Sanitizer: Keep reference unchanged
else Not in allowlist
Sanitizer->>Sanitizer: Rewrite to "# PRIVATE:" sentinel and emit warning
end
Sanitizer-->>Bundler: Return sanitized bundle and change flag
else link_allow_repos absent
Bundler-->>Bundler: Skip link filtering
end
Bundler-->>Output: Finalized bundle
Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@config/changelog.example.yml`:
- Around line 215-221: Remove the live entries from the example config so new
projects don't enable filtering by default: in the changelog example YAML change
the link_allow_repos block to be empty (e.g. link_allow_repos: [] ) or replace
the populated list with commented example values, and ensure the template
emitted by the docs-builder "changelog init" command uses that empty/commented
allowlist (refer to the link_allow_repos key and the changelog init generator in
ChangelogCommand.cs).
In `@src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs`:
- Around line 234-248: The code unconditionally reads assembler.yml and calls
LinkAllowlistSanitizer.EmitAssemblerDiagnostics even when
bundle.link_allow_repos is an empty list, which causes unnecessary file I/O and
misleading warnings; update the block that uses configurationContext and
linkAllowRepos (the variable passed as linkAllowRepos! to
EmitAssemblerDiagnostics) to first check that linkAllowRepos is not null and not
empty (e.g., Count > 0) and only then perform ReadToEnd, Deserialize, and call
LinkAllowlistSanitizer.EmitAssemblerDiagnostics; keep the existing exception
filter and collector.EmitWarning behavior for real I/O/deserialize failures.
In `@src/services/Elastic.Changelog/Bundling/ChangelogBundlingService.cs`:
- Around line 296-310: Skip loading assembler.yml and running
LinkAllowlistSanitizer.EmitAssemblerDiagnostics when there are no allowlist
entries: guard the whole configurationContext block with a check that
input.LinkAllowRepos.Count > 0 (or Any()) before attempting to read
configurationContext.ConfigurationFileProvider.AssemblerFile or calling
LinkAllowlistSanitizer.EmitAssemblerDiagnostics; this prevents unnecessary reads
and warnings when the allowlist is empty while keeping existing exception
handling around AssemblyConfiguration.Deserialize and the collector.EmitWarning
behavior.
In `@src/services/Elastic.Changelog/Bundling/LinkAllowlistSanitizer.cs`:
- Around line 133-135: The current check in LinkAllowlistSanitizer returns an
empty list for null/empty refs ("return refs ?? []"), which converts originally
null Prs/Issues to empty arrays while changesApplied remains false; change the
early return to preserve null by returning refs directly (e.g., replace "return
refs ?? []" with "return refs") so that null lists remain null and untouched
bundles are not rewritten; adjust in the same method where the local variable
refs and the changesApplied flag are used.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c3f6fb9c-660f-49b7-8319-677783ca2724
📒 Files selected for processing (14)
config/changelog.example.ymldocs/changelog/changelog-private-link-sanitization.yamldocs/cli/changelog/bundle.mddocs/contribute/changelog.mdsrc/Elastic.Documentation.Configuration/Changelog/BundleConfiguration.cssrc/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cssrc/services/Elastic.Changelog/Bundling/ChangelogBundlingService.cssrc/services/Elastic.Changelog/Bundling/LinkAllowlistSanitizer.cssrc/services/Elastic.Changelog/Bundling/PrivateChangelogLinkSanitizer.cssrc/services/Elastic.Changelog/Configuration/ChangelogConfigurationLoader.cssrc/services/Elastic.Changelog/Serialization/ChangelogConfigurationYaml.cssrc/tooling/docs-builder/Commands/ChangelogCommand.cstests/Elastic.Changelog.Tests/Changelogs/LinkAllowlistSanitizerTests.cstests/Elastic.Changelog.Tests/Changelogs/PrivateChangelogLinkSanitizerTests.cs
💤 Files with no reviewable changes (2)
- src/services/Elastic.Changelog/Bundling/PrivateChangelogLinkSanitizer.cs
- tests/Elastic.Changelog.Tests/Changelogs/PrivateChangelogLinkSanitizerTests.cs
src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs
Outdated
Show resolved
Hide resolved
src/services/Elastic.Changelog/Bundling/ChangelogBundlingService.cs
Outdated
Show resolved
Hide resolved
src/services/Elastic.Changelog/Bundling/LinkAllowlistSanitizer.cs
Outdated
Show resolved
Hide resolved
Here’s what was implemented: 1. Assembler diagnostics guards
2. Preserve
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs (1)
220-221: Consider extracting duplicated owner/repo logic.Lines 220-221 duplicate the owner/repo extraction from lines 168-169. Minor DRY improvement opportunity—could extract a local helper, but not blocking.
♻️ Optional: Extract helper
+ static (string owner, string? repo) GetOwnerRepo(Bundle bundle) => + bundle.Products.Count > 0 + ? (bundle.Products[0].Owner ?? "elastic", bundle.Products[0].Repo) + : ("elastic", null);Then use
var (owner, repo) = GetOwnerRepo(parentBundleForAllowlist);in both locations.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs` around lines 220 - 221, Duplicate logic extracts owner/repo from parentBundleForAllowlist in two places; extract a small helper to avoid repetition. Add a private method like GetOwnerRepo(ParentBundleType parentBundleForAllowlist) that returns (string owner, string repo) or a ValueTuple, implement the same logic currently used (default owner "elastic", repo null if no products), and replace both inline expressions (the occurrences around parentBundleForAllowlist.Products access) with var (owner, repo) = GetOwnerRepo(parentBundleForAllowlist); to centralize behavior and keep semantics identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs`:
- Around line 220-221: Duplicate logic extracts owner/repo from
parentBundleForAllowlist in two places; extract a small helper to avoid
repetition. Add a private method like GetOwnerRepo(ParentBundleType
parentBundleForAllowlist) that returns (string owner, string repo) or a
ValueTuple, implement the same logic currently used (default owner "elastic",
repo null if no products), and replace both inline expressions (the occurrences
around parentBundleForAllowlist.Products access) with var (owner, repo) =
GetOwnerRepo(parentBundleForAllowlist); to centralize behavior and keep
semantics identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0ee91852-c2dd-4157-a4ce-0698287ba521
📒 Files selected for processing (5)
config/changelog.example.ymlsrc/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cssrc/services/Elastic.Changelog/Bundling/ChangelogBundlingService.cssrc/services/Elastic.Changelog/Bundling/LinkAllowlistSanitizer.cstests/Elastic.Changelog.Tests/Changelogs/LinkAllowlistSanitizerTests.cs
✅ Files skipped from review due to trivial changes (1)
- src/services/Elastic.Changelog/Bundling/ChangelogBundlingService.cs
🚧 Files skipped from review as they are similar to previous changes (3)
- config/changelog.example.yml
- src/services/Elastic.Changelog/Bundling/LinkAllowlistSanitizer.cs
- tests/Elastic.Changelog.Tests/Changelogs/LinkAllowlistSanitizerTests.cs
Summary
Replaces the assembler-based private-link sanitization (#3002) with an explicit allowlist model (no implicit allow).
Design principles
bundle.link_allow_repos(this avoids confusion of whether the current repo is included/excluded particularly when it's a private repo )# PRIVATE:sentinel + warn in diagnostics# PRIVATE:skip logic from PR Add changelog bundle support for hiding private links #3002Implementation details
LinkAllowlistSanitizer.cswithTryApplyBundle()and optionalEmitAssemblerDiagnostics().BundleConfiguration— replacedSanitizePrivateLinks(bool) withLinkAllowRepos(list), removed profileSanitizePrivateLinks.ParseBundleConfiguration()to parselink_allow_reposviaYamlLenientList, validatebundle.repohas no+syntax.LinkAllowReposintoBundleChangelogsArguments,ApplyConfigDefaults(), and allowlist application with optional assembler warnings.--sanitize-private-links/--no-sanitize-private-linksflags and profile field fromChangelogCommand.cs.PrivateChangelogLinkSanitizerTests.cswithLinkAllowlistSanitizerTests.cs(allowlist-focused; keptTryGetGitHubRepo/GetFirstRepoSegmentFromBundleRepotests).bundle.md(new "PR and issue link allowlist" section),changelog.md(replacedsanitize_private_linkswithlink_allow_repos),config/changelog.example.yml(updated examples), andchangelog-private-link-sanitization.yaml(update notes).PrivateChangelogLinkSanitizer.cs.Steps to test
Generative AI disclosure
Tool(s) and model(s) used: composer-2, claude-4.5-haiku