Skip to content

fix: stream multipart upload in UploadArtifact to avoid unbounded mem…#372

Merged
Harsh4902 merged 1 commit into
microcks:masterfrom
abhaygoudannavar:fix/stream-upload-artifact
May 14, 2026
Merged

fix: stream multipart upload in UploadArtifact to avoid unbounded mem…#372
Harsh4902 merged 1 commit into
microcks:masterfrom
abhaygoudannavar:fix/stream-upload-artifact

Conversation

@abhaygoudannavar
Copy link
Copy Markdown
Contributor

Description

  • Replaced in-memory bytes.Buffer with io.Pipe() streaming in UploadArtifact (pkg/connectors/microcks_client.go). Multipart form data is now written in a background goroutine and streamed directly from disk to the HTTP request, keeping memory usage constant regardless of artifact file size.
  • Replaced two panic() calls with proper fmt.Errorf error returns in the upload path, matching the style of recent fixes (e.g., f9f282c).
  • Added TestUploadArtifactStreamsWithoutBuffering test (pkg/connectors/microcks_client_test.go) covering file content integrity, filename, mainArtifact field, and HTTP response handling.

Test results:
$ go test ./pkg/connectors/... ok github.com/microcks/microcks-cli/pkg/connectors 0.022s

Related issue(s)

Fixes #324

…ory allocation

Replace bytes.Buffer with io.Pipe() in UploadArtifact so multipart form
data is streamed directly from disk to the HTTP request. This keeps
memory usage constant regardless of artifact file size, preventing OOM
kills on constrained CI/CD runners.

Also replaces panic() calls with proper error returns in the upload path.

Fixes microcks#324

Signed-off-by: abhaygoudannavar <abhaysgoudnvr@gmail.com>
@abhaygoudannavar
Copy link
Copy Markdown
Contributor Author

@Harsh4902 i worked on #324 any changes is needed in the pr?

@Harsh4902 Harsh4902 added this to the Next milestone May 14, 2026
Copy link
Copy Markdown
Member

@Harsh4902 Harsh4902 left a comment

Choose a reason for hiding this comment

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

Thanks @abhaygoudannavar for this contribution. LGTM

@Harsh4902 Harsh4902 merged commit 5aafea1 into microcks:master May 14, 2026
8 checks passed
@github-actions
Copy link
Copy Markdown

🎉 @abhaygoudannavar

You are now a Microcks community contributor! 💖

Thanks and congrats 🚀 on merging your first pull request! We are delighted and very proud of you! 👏

📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌"

Kudos and please keep going, we need you 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unbounded memory allocation in UploadArtifact due to in-memory multipart buffering

2 participants