Skip to content

Changelogs: Add bundle uploads#3054

Open
cotti wants to merge 3 commits intomainfrom
feature/bundle_upload
Open

Changelogs: Add bundle uploads#3054
cotti wants to merge 3 commits intomainfrom
feature/bundle_upload

Conversation

@cotti
Copy link
Copy Markdown
Contributor

@cotti cotti commented Apr 8, 2026

Unblocks elastic/docs-actions#42

This pull request adds support for uploading "bundle" artifacts in the changelog upload service. It introduces logic to discover and upload bundle YAML files, validates product names, and updates the tests to cover this new functionality. The changes also ensure that multiple products in a bundle are handled correctly, and invalid product names are skipped with appropriate warnings.

Bundle artifact upload support:

  • Implemented DiscoverBundleUploadTargets to find bundle YAML files, validate product names, and create an upload target for each valid product in the bundle. Invalid product names are skipped with a warning.
  • Added ReadProductsFromBundle to extract product IDs from bundle files.
  • Added ResolveBundleDirectory to determine the correct directory for bundle artifacts, supporting both explicit and configuration-based paths.

Upload logic enhancements:

  • Updated the main Upload method to support the new bundle artifact type: resolves the correct directory, discovers bundle upload targets, and logs details using the artifact type.

Test coverage improvements:

  • Updated and expanded tests to verify that bundle artifacts are uploaded to S3, that multiple products in a bundle create multiple upload targets, and that invalid product names are skipped with warnings. [1] [2]

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 38572eff-8ab3-4bba-a68f-a891bddd0549

📥 Commits

Reviewing files that changed from the base of the PR and between ca9f555 and 83dd449.

📒 Files selected for processing (1)
  • src/services/Elastic.Changelog/Uploading/ChangelogUploadService.cs

📝 Walkthrough

Walkthrough

The changelog upload service no longer skips ArtifactType.Bundle early and instead routes bundle uploads through the common Upload(...) flow. Directory resolution is artifact-type-specific (ResolveBundleDirectory vs ResolveChangelogDirectory). Target discovery now uses DiscoverBundleUploadTargets for bundles (producing per-product S3 keys under {product}/bundles/{fileName}) and DiscoverUploadTargets for changelogs. Bundles are parsed via ReadProductsFromBundle (deserializing bundle YAML and extracting product IDs) with validation and warnings on errors; discovered targets are uploaded to S3 via the existing uploader.

Sequence Diagram

sequenceDiagram
    participant Client
    participant ChangelogUploadService
    participant DirectoryResolver
    participant BundleDiscovery
    participant BundleDeserializer
    participant ProductValidator
    participant S3Uploader

    Client->>ChangelogUploadService: Upload(args with ArtifactType=Bundle)
    activate ChangelogUploadService

    ChangelogUploadService->>DirectoryResolver: ResolveBundleDirectory(args, config)
    activate DirectoryResolver
    DirectoryResolver-->>ChangelogUploadService: bundleDirectory
    deactivate DirectoryResolver

    ChangelogUploadService->>BundleDiscovery: DiscoverBundleUploadTargets(bundleDirectory)
    activate BundleDiscovery
    BundleDiscovery->>BundleDiscovery: Find top-level *.yaml/*.yml files

    BundleDiscovery->>BundleDeserializer: ReadProductsFromBundle(bundleFile)
    activate BundleDeserializer
    BundleDeserializer->>BundleDeserializer: Deserialize YAML, extract distinct ProductIds
    BundleDeserializer-->>BundleDiscovery: productIds[]
    deactivate BundleDeserializer

    BundleDiscovery->>ProductValidator: Validate product names (ProductNameRegex)
    activate ProductValidator
    ProductValidator-->>BundleDiscovery: valid/invalid
    deactivate ProductValidator

    BundleDiscovery->>BundleDiscovery: Emit UploadTarget per valid product (S3Key = {product}/bundles/{fileName})
    BundleDiscovery-->>ChangelogUploadService: UploadTarget[]
    deactivate BundleDiscovery

    ChangelogUploadService->>S3Uploader: PutObjectAsync(uploadTargets)
    activate S3Uploader
    S3Uploader-->>ChangelogUploadService: Upload responses
    deactivate S3Uploader

    ChangelogUploadService-->>Client: Result/diagnostics
    deactivate ChangelogUploadService
Loading
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Changelogs: Add bundle uploads' directly and clearly describes the main feature being added—bundle upload support for the changelog service.
Description check ✅ Passed The description is detailed and directly related to the changeset, explaining the new bundle upload functionality, specific methods implemented, and test coverage additions.

✏️ 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 feature/bundle_upload

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

Copy link
Copy Markdown
Contributor

@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

🧹 Nitpick comments (1)
src/services/Elastic.Changelog/Uploading/ChangelogUploadService.cs (1)

142-184: Consider extracting shared logic with DiscoverUploadTargets.

This method is nearly identical to DiscoverUploadTargets (lines 98-140), differing only in the product extraction call and S3 key path segment (bundles vs changelogs). A shared helper could reduce duplication, but it's not critical given the slight behavioral differences.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/services/Elastic.Changelog/Uploading/ChangelogUploadService.cs` around
lines 142 - 184, DiscoverBundleUploadTargets duplicates DiscoverUploadTargets;
extract a shared helper to remove duplication by factoring the common file
enumeration, symlink validation (SymlinkValidator.ValidateFileAccess), product
name validation (ProductNameRegex), and UploadTarget creation, and pass the
differing pieces (product extraction function ReadProductsFromBundle vs existing
extractor and the S3 segment string "bundles" vs "changelogs") as parameters
(e.g., Func<string,IReadOnlyList<string>> productExtractor and string
s3Segment). Replace DiscoverBundleUploadTargets and DiscoverUploadTargets to
call the new helper, keeping UploadTarget creation and filePath/fileName logic
centralized and preserving the collector warnings and logger usage.
🤖 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/services/Elastic.Changelog/Uploading/ChangelogUploadService.cs`:
- Around line 186-204: ReadProductsFromBundle currently assumes
ReleaseNotesSerialization.DeserializeBundle(content) returns a non-null bundle
and accesses bundle.Products directly, relying on exceptions to handle nulls;
update ReadProductsFromBundle to check for nulls like ReadProductsFromFragment
does: after deserializing (ReleaseNotesSerialization.DeserializeBundle) verify
if bundle == null or bundle.Products == null and return new List<string>()
early, then proceed with the LINQ (Select p => p.ProductId ...
Distinct().ToList()); keep the existing catch/logging behavior but replace the
invalid [] return with new List<string>().

---

Nitpick comments:
In `@src/services/Elastic.Changelog/Uploading/ChangelogUploadService.cs`:
- Around line 142-184: DiscoverBundleUploadTargets duplicates
DiscoverUploadTargets; extract a shared helper to remove duplication by
factoring the common file enumeration, symlink validation
(SymlinkValidator.ValidateFileAccess), product name validation
(ProductNameRegex), and UploadTarget creation, and pass the differing pieces
(product extraction function ReadProductsFromBundle vs existing extractor and
the S3 segment string "bundles" vs "changelogs") as parameters (e.g.,
Func<string,IReadOnlyList<string>> productExtractor and string s3Segment).
Replace DiscoverBundleUploadTargets and DiscoverUploadTargets to call the new
helper, keeping UploadTarget creation and filePath/fileName logic centralized
and preserving the collector warnings and logger usage.
🪄 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: 2115e415-e8ad-4c94-9eab-7713aeb89dd5

📥 Commits

Reviewing files that changed from the base of the PR and between 4ffc7ee and ca9f555.

📒 Files selected for processing (2)
  • src/services/Elastic.Changelog/Uploading/ChangelogUploadService.cs
  • tests/Elastic.Changelog.Tests/Uploading/ChangelogUploadServiceTests.cs

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.

1 participant