feat(eng-12002): Add metadata flag to push command#293
Open
BartoszBlizniak wants to merge 7 commits into
Open
Conversation
|
@claude review (Sent as an external user with no permissions) |
cloudsmith-iduffy
approved these changes
May 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds push-time metadata support so package uploads can validate and attach metadata during cloudsmith push.
Changes:
- Adds metadata resolution, validation, attachment, retry hints, and failure-mode handling to push commands.
- Surfaces metadata attachment status in JSON success/error output.
- Adds extensive unit coverage for metadata validation, attachment, warnings, retry hints, and JSON envelopes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
cloudsmith_cli/cli/commands/push.py |
Implements push-time metadata options and attachment flow. |
cloudsmith_cli/cli/exceptions.py |
Adds metadata context to JSON API error envelopes. |
cloudsmith_cli/cli/tests/test_push.py |
Adds tests for push metadata behaviors and helper output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…--on-metadata-failure flag and metadata_failure_mode config key alongside the existing CLOUDSMITH_METADATA_FAILURE_MODE env var. Precedence: flag > env > config > default (error). Env-var path stays backward-compatible.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds push-time metadata flags to
cloudsmith push <format>so SBOM / BuildInfo / generic JSON can be attached in a single command instead of a separatecloudsmith metadata addfollow-up.New flags on every push subcommand:
--metadata-content-file PATH(or-for stdin)--metadata-content JSON--metadata-content-type MIME--metadata-source-identity TEXT--on-metadata-failure [error|warn]Flow:
UsageError— a single metadata payload semantically belongs to one package, so silently fanning it out across N packages (and validating + attaching it N times) is almost never the intent. Push files individually when attaching metadata.POST /v2/metadata/validate/before any S3 upload — malformed metadata can no longer leave orphan packages.create_package, attach metadata viaPOST /v2/metadata/.--on-metadata-failure warnflag,CLOUDSMITH_METADATA_FAILURE_MODE=warn(or0) env var, ormetadata_failure_mode = warninconfig.ini. Precedence: flag > env > config > default (error). Downgrades to a warning + copy-paste retry hint.metadata_attachmentin JSON output (success and error envelopes).Reuses shared metadata helpers from
cli/metadata_common.pyType of Change
Additional Notes
--on-metadata-failure warnflag (per push),CLOUDSMITH_METADATA_FAILURE_MODE=warnenv var (per shell / CI step),metadata_failure_mode = warninconfig.ini(persistent). Precedence: flag > env > config > default. Invalid config-file values raise aUsageErrorat load time instead of silently falling back toerror.cloudsmith push <format> ... file1 file2 ...) combined with any metadata flag is rejected up-front with aUsageError. Push files individually when attaching metadata, or drop the flags for a bulk upload.Examples
Push:
Push with invalid metadata (default, hard fail):
Push with invalid metadata, downgraded via the
--on-metadata-failure warnflag:Same downgrade via the env var (backward-compatible path for CI wrappers):
Or persistently via
~/.config/cloudsmith/config.ini:Resolution order when more than one is set:
--on-metadata-failureflag >$CLOUDSMITH_METADATA_FAILURE_MODEenv var >metadata_failure_modeconfig key > default (error).