Skip to content

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

Open
lcawl wants to merge 4 commits into
mainfrom
bundle-remove
Open

[Release notes] Add bundle-amend --remove option#3513
lcawl wants to merge 4 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

Warning

Review limit reached

@lcawl, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 19 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 05dce845-b1ee-4a1c-844c-dc558284e2fb

📥 Commits

Reviewing files that changed from the base of the PR and between 6371988 and 7050eea.

📒 Files selected for processing (1)
  • docs/cli/changelog/cmd-remove.md
📝 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
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% 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 clearly and concisely summarizes the main change: adding a --remove option to the bundle-amend command.
Description check ✅ Passed The description comprehensively explains the feature, core changes, tests added, example usage, and testing methodology, all directly related to the changeset.
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
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.

1 participant