Skip to content

[Release notes] Add bundle-amend --remove option#3513

Merged
lcawl merged 7 commits into
mainfrom
bundle-remove
Jun 24, 2026
Merged

[Release notes] Add bundle-amend --remove option#3513
lcawl merged 7 commits into
mainfrom
bundle-remove

Conversation

@lcawl

@lcawl lcawl commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a --remove option to the docs-builder changelog bundle-amend command, so that changelogs can be removed from bundles post-release if necessary.

Previously, the bundle had to be manually edited or entirely replaced.

Core changes

  1. Schema — Added exclude-entries to Bundle.cs, BundleDto, and ReleaseNotesSerialization.cs.

  2. BundleAmendMerger — New shared merger in BundleAmendMerger.cs: per amend file, apply exclusions then additions; ordered by amend number.

  3. Merge wiring — Updated BundleLoader.cs and BundleValidationService.cs to use the merger.

  4. ChangelogBundleAmendService — Supports --remove, --force, and --dry-run; writes exclude-entries to new .amend-N.yaml sidecars; checksum matching with optional --force for name-only removal.

  5. CLIChangelogCommand.BundleAmend accepts --remove, --force, --dry-run; requires at least one of --add or --remove.

  6. changelog removeChangelogRemoveService uses the effective bundle (parent + amends − exclusions) for dependency checks; skips amend files as parent bundle candidates.

Tests added

Example usage

# Remove from effective bundle (parent stays untouched)
docs-builder changelog bundle-amend ./bundles/9.3.0.yaml \
  --remove ./docs/changelog/138723.yaml

# Replace in one amend
docs-builder changelog bundle-amend ./bundles/9.3.0.yaml \
  --remove ./docs/changelog/old.yaml \
  --add ./docs/changelog/new.yaml

Steps for testing

I tested this command as follows:

  1. Generate artifacts:
    ./build.sh clean
    ./build.sh publishbinaries
  2. Check out a repo that has changelog bundles, for example, https://github.com/elastic/elastic-otel-java/tree/main
  3. Run the changelog bundle-amend command to remove a changelog. For example, I tested against a bundle with a single changelog in the aforementioned repo:
    /path/docs-builder/.artifacts/publish/docs-builder/release/docs-builder changelog bundle-amend ./docs/releases/1.11.0.yaml --remove ./docs/changelog/upstream-update.yaml 
    The command failed with this message:
    Error: Bundle contains 'upstream-update.yaml' but with a different checksum than the file on disk. Re-create the bundle or use --force to remove by file name only.
    NOTE: /path/elastic-otel-java/docs/changelog/upstream-update.yaml
    When I re-ran the command with the --force option, it successfully created a docs/releases/1.11.0.amend-1.yaml file with the following contents:
    exclude-entries:
    - file:
    name: upstream-update.yaml
    checksum: 3a0887aa3976c53f032f3952f33a95238fb55fa9
    The release note page that uses a changelog directive to render these bundles correctly shows the release (and its description) but the single changelog no longer appears:
    image

NOTE: If you try to remove a changelog from a bundle but you don't have access to the changelog file anymore, you get an error like this:

Error: File does not exist. Current directory: ... Tip: Repeat --remove for each file, or use comma-separated values (e.g., --remove "file1.yaml,file2.yaml"). Paths support tilde (~) expansion and can be relative or absolute.
NOTE: /path/GitHub/elastic-otel-java/835.yaml

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: composer-2.5-fast

@lcawl lcawl temporarily deployed to integration-tests June 16, 2026 01:01 — with GitHub Actions Inactive
@lcawl lcawl marked this pull request as ready for review June 16, 2026 01:42
@lcawl lcawl requested review from a team as code owners June 16, 2026 01:42
@lcawl lcawl requested a review from theletterf June 16, 2026 01:42
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 14b1f4a5-bac0-46d6-818c-e584fc4a87d5

📥 Commits

Reviewing files that changed from the base of the PR and between 747f620 and c04d49f.

📒 Files selected for processing (2)
  • src/Elastic.Documentation.Configuration/ReleaseNotes/BundleLoader.cs
  • src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs

📝 Walkthrough

Walkthrough

The PR adds the ability to remove changelog entries from published bundles via a new --remove flag on the changelog bundle-amend CLI command. A new ExcludeEntries property is added to the Bundle domain record and BundleDto DTO, serialized as exclude-entries in YAML. A new BundleAmendMerger utility handles amend-file detection, numeric ordering, and the merge algorithm (exclusions applied before additions per amend). BundleLoader, BundleValidationService, and ChangelogRemoveService are updated to use this merger. ChangelogBundleAmendService gains --remove, --force, and --dry-run support with checksum-based exclusion matching. Documentation and tests cover all new behaviors.

Sequence Diagram

sequenceDiagram
  rect rgba(100, 149, 237, 0.5)
    note over CLI,FS: bundle-amend --remove flow
  end
  participant CLI as docs-builder CLI
  participant ChangelogCommand
  participant AmendService as ChangelogBundleAmendService
  participant Merger as BundleAmendMerger
  participant FS as FileSystem / YAML

  CLI->>ChangelogCommand: bundle-amend --remove file.yaml [--force] [--dry-run]
  ChangelogCommand->>ChangelogCommand: normalize paths, validate at least one of --add/--remove
  ChangelogCommand->>AmendService: AmendBundle(AmendBundleArguments)
  AmendService->>FS: deserialize parent bundle + existing amend bundles
  AmendService->>Merger: CollectAppliedExclusionKeys(existingAmends)
  loop each RemoveFile
    AmendService->>FS: read file, compute checksum
    AmendService->>Merger: EntryMatchesExclusion(entry, exclusion)
    AmendService->>Merger: BuildExclusionKey(exclusion)
    AmendService-->>AmendService: BuildExclusionEntryAsync → Add | Skip | fail
  end
  AmendService->>Merger: MergeEntries(parentEntries, existingAmends)
  alt --dry-run
    AmendService-->>CLI: return success (no write)
  else write amend
    AmendService->>FS: write .amend-N.yaml with exclude-entries + entries
    AmendService-->>CLI: return success
  end
Loading

Possibly related PRs

  • elastic/docs-builder#3436: Both PRs touch the release-notes bundle loading/merge flow around amend sidecar files; this PR adds exclude-entries-aware BundleAmendMerger and threads it through BundleLoader.MergeAmendFiles/LoadBundlesFromContent, while that PR adds CDN-backed bundle fetching.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main feature added: a --remove option to the bundle-amend command, which is the central change across the entire changeset.
Description check ✅ Passed The description is well-organized and directly related to the changeset, providing a comprehensive summary of core changes, tests added, usage examples, and testing methodology.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch bundle-remove

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/syntax/changelog.md (1)

322-326: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Don't recommend --remove as a fix for an already-missing file.

The PR notes this path still fails once the changelog file is no longer on disk. For that case, tell readers to restore the file or re-bundle with --resolve; bundle-amend --remove only applies while the source changelog is still available.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/syntax/changelog.md` around lines 322 - 326, The documentation in the
changelog.md file currently recommends using `bundle-amend --remove` as a
general fix for missing changelog files, but this option only works when the
source changelog file is still available on disk. Remove the `--remove` option
from the list of fixes in the bullet points, or alternatively, add a note
clarifying that this option only applies when the source file exists. Keep only
the two viable fixes for missing files: restoring the missing changelog files or
re-creating the bundle with `--resolve` to embed entry content directly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Elastic.Documentation.Configuration/ReleaseNotes/BundleLoader.cs`:
- Around line 281-313: Orphan amend files that don't have a corresponding parent
bundle are being included in the final bundle output as standalone bundles
because they are not added to mergedAmendPaths when the parent lookup fails.
When the bundlesByPath.TryGetValue check fails for parentPath and the continue
statement executes at line 288, you must still add all amend files in the
current group to mergedAmendPaths before continuing, so that these orphan amend
files are properly excluded from the final returned bundle list.

In `@src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs`:
- Around line 341-349: In the LoadExistingAmendBundlesAsync method, the call to
ReleaseNotesSerialization.DeserializeBundle on line 348 lacks error handling for
malformed YAML. Wrap the ReadAllTextAsync and DeserializeBundle calls in a
try-catch block to catch deserialization exceptions, log the error for
diagnostics purposes, and continue processing the remaining amend files instead
of allowing the exception to propagate and crash the service.

In `@src/services/Elastic.Changelog/Bundling/ChangelogRemoveService.cs`:
- Around line 360-366: The deserialization of individual amend files using
ReleaseNotesSerialization.DeserializeBundle at lines 360-366 is not protected,
so if one amend file fails to deserialize, the exception propagates to the outer
catch block and skips dependency analysis for the entire parent bundle,
potentially allowing deletion of required files. Wrap the
ReleaseNotesSerialization.DeserializeBundle call in a try-catch block within the
loop over amendPaths so that individual deserialization failures are handled
gracefully without preventing the parent bundle's dependency analysis. Only add
valid deserialized bundles to amendBundles and continue processing remaining
amend files. Apply the same fix to the second location mentioned at lines
394-397.

---

Outside diff comments:
In `@docs/syntax/changelog.md`:
- Around line 322-326: The documentation in the changelog.md file currently
recommends using `bundle-amend --remove` as a general fix for missing changelog
files, but this option only works when the source changelog file is still
available on disk. Remove the `--remove` option from the list of fixes in the
bullet points, or alternatively, add a note clarifying that this option only
applies when the source file exists. Keep only the two viable fixes for missing
files: restoring the missing changelog files or re-creating the bundle with
`--resolve` to embed entry content directly.
🪄 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: Enterprise

Run ID: 794f960c-9f1a-4c58-8bf0-efb55995e9c3

📥 Commits

Reviewing files that changed from the base of the PR and between cbf939c and a642d7b.

📒 Files selected for processing (19)
  • docs/cli-schema.json
  • docs/cli/changelog/cmd-bundle-amend.md
  • docs/contribute/bundle-changelogs.md
  • docs/syntax/changelog.md
  • src/Elastic.Documentation.Configuration/ReleaseNotes/Bundle.cs
  • src/Elastic.Documentation.Configuration/ReleaseNotes/BundleAmendMerger.cs
  • src/Elastic.Documentation.Configuration/ReleaseNotes/BundleLoader.cs
  • src/Elastic.Documentation.Configuration/ReleaseNotes/ReleaseNotesSerialization.cs
  • src/Elastic.Documentation/ReleaseNotes/Bundle.cs
  • src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs
  • src/services/Elastic.Changelog/Bundling/ChangelogRemoveService.cs
  • src/services/Elastic.Changelog/Rendering/BundleValidationService.cs
  • src/tooling/docs-builder/Commands/ChangelogCommand.cs
  • tests/Elastic.Changelog.Tests/Changelogs/BundleAmendMergerTests.cs
  • tests/Elastic.Changelog.Tests/Changelogs/BundleAmendTests.cs
  • tests/Elastic.Changelog.Tests/Changelogs/BundleLoading/BundleLoaderTests.cs
  • tests/Elastic.Changelog.Tests/Changelogs/ChangelogRemoveTests.cs
  • tests/Elastic.Changelog.Tests/Changelogs/Render/BundleValidationTests.cs
  • tests/Elastic.Markdown.Tests/Directives/ChangelogBasicTests.cs

Comment thread src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs Outdated
Comment thread src/services/Elastic.Changelog/Bundling/ChangelogRemoveService.cs
@lcawl lcawl temporarily deployed to integration-tests June 16, 2026 02:46 — with GitHub Actions Inactive
@lcawl lcawl temporarily deployed to integration-tests June 16, 2026 15:01 — with GitHub Actions Inactive
@lcawl lcawl temporarily deployed to integration-tests June 16, 2026 16:22 — with GitHub Actions Inactive

@Mpdreamz Mpdreamz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good feature overall — the BundleAmendMerger extraction is clean and the test coverage is solid. Two issues worth fixing before merge.

Comment thread src/services/Elastic.Changelog/Bundling/ChangelogBundleAmendService.cs Outdated
@lcawl lcawl had a problem deploying to integration-tests June 19, 2026 22:41 — with GitHub Actions Failure

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Elastic.Documentation.Configuration/ReleaseNotes/BundleLoader.cs`:
- Line 97: The call to MergeAmendFiles on line 97 in the LoadBundlesFromContent
method is missing a required parameter, causing a compile error due to arity
mismatch. Add the missing emitWarning parameter to the MergeAmendFiles method
call to match its expected signature. Determine the appropriate value for the
emitWarning parameter based on the context of how this method should behave and
the overall design of the LoadBundlesFromContent method.
🪄 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: Enterprise

Run ID: 49523e79-88c4-426d-bd01-3c5c01418a61

📥 Commits

Reviewing files that changed from the base of the PR and between 6371988 and 747f620.

📒 Files selected for processing (8)
  • docs/cli-schema.json
  • docs/cli/changelog/cmd-remove.md
  • docs/syntax/changelog.md
  • src/Elastic.Documentation.Configuration/ReleaseNotes/BundleLoader.cs
  • src/services/Elastic.Changelog/Rendering/BundleValidationService.cs
  • src/tooling/docs-builder/Commands/ChangelogCommand.cs
  • tests/Elastic.Changelog.Tests/Changelogs/BundleLoading/BundleLoaderTests.cs
  • tests/Elastic.Markdown.Tests/Directives/ChangelogBasicTests.cs
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/Elastic.Markdown.Tests/Directives/ChangelogBasicTests.cs
  • src/tooling/docs-builder/Commands/ChangelogCommand.cs
  • tests/Elastic.Changelog.Tests/Changelogs/BundleLoading/BundleLoaderTests.cs
  • docs/cli-schema.json
  • src/services/Elastic.Changelog/Rendering/BundleValidationService.cs

@coderabbitai coderabbitai Bot 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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Elastic.Documentation.Configuration/ReleaseNotes/BundleLoader.cs`:
- Line 97: The call to MergeAmendFiles on line 97 in the LoadBundlesFromContent
method is missing a required parameter, causing a compile error due to arity
mismatch. Add the missing emitWarning parameter to the MergeAmendFiles method
call to match its expected signature. Determine the appropriate value for the
emitWarning parameter based on the context of how this method should behave and
the overall design of the LoadBundlesFromContent method.
🪄 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: Enterprise

Run ID: 49523e79-88c4-426d-bd01-3c5c01418a61

📥 Commits

Reviewing files that changed from the base of the PR and between 6371988 and 747f620.

📒 Files selected for processing (8)
  • docs/cli-schema.json
  • docs/cli/changelog/cmd-remove.md
  • docs/syntax/changelog.md
  • src/Elastic.Documentation.Configuration/ReleaseNotes/BundleLoader.cs
  • src/services/Elastic.Changelog/Rendering/BundleValidationService.cs
  • src/tooling/docs-builder/Commands/ChangelogCommand.cs
  • tests/Elastic.Changelog.Tests/Changelogs/BundleLoading/BundleLoaderTests.cs
  • tests/Elastic.Markdown.Tests/Directives/ChangelogBasicTests.cs
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/Elastic.Markdown.Tests/Directives/ChangelogBasicTests.cs
  • src/tooling/docs-builder/Commands/ChangelogCommand.cs
  • tests/Elastic.Changelog.Tests/Changelogs/BundleLoading/BundleLoaderTests.cs
  • docs/cli-schema.json
  • src/services/Elastic.Changelog/Rendering/BundleValidationService.cs
🛑 Comments failed to post (1)
src/Elastic.Documentation.Configuration/ReleaseNotes/BundleLoader.cs (1)

97-97: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix method call arity mismatch in LoadBundlesFromContent.

Line 97 calls MergeAmendFiles without the required emitWarning parameter, which causes a compile error.

Suggested fix
-		return MergeAmendFiles(loadedBundles);
+		return MergeAmendFiles(loadedBundles, emitWarning);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

		return MergeAmendFiles(loadedBundles, emitWarning);
🧰 Tools
🪛 GitHub Check: integration

[failure] 97-97:
There is no argument given that corresponds to the required parameter 'emitWarning' of 'BundleLoader.MergeAmendFiles(List, Action)'


[failure] 97-97:
There is no argument given that corresponds to the required parameter 'emitWarning' of 'BundleLoader.MergeAmendFiles(List, Action)'

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Elastic.Documentation.Configuration/ReleaseNotes/BundleLoader.cs` at line
97, The call to MergeAmendFiles on line 97 in the LoadBundlesFromContent method
is missing a required parameter, causing a compile error due to arity mismatch.
Add the missing emitWarning parameter to the MergeAmendFiles method call to
match its expected signature. Determine the appropriate value for the
emitWarning parameter based on the context of how this method should behave and
the overall design of the LoadBundlesFromContent method.

Source: Linters/SAST tools

@lcawl lcawl temporarily deployed to integration-tests June 19, 2026 23:39 — with GitHub Actions Inactive
@lcawl lcawl temporarily deployed to integration-tests June 22, 2026 16:20 — with GitHub Actions Inactive
@lcawl lcawl merged commit 94a6131 into main Jun 24, 2026
33 of 34 checks passed
@lcawl lcawl deleted the bundle-remove branch June 24, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants