Skip to content

Conversation

@migmartri
Copy link
Member

@migmartri migmartri commented Nov 13, 2025

Summary

Add a new --existing-version flag to the attestation init command that fails if the specified project version doesn't already exist in the system.

Use Case

When running packaging tasks, users want to ensure that backpatches are associated with existing versions rather than creating new ones accidentally.

Implementation

  • Added require_existing_version field to AttestationServiceInitRequest proto
  • Added validation in data layer that returns ErrVersionNotFound if flag is true and version doesn't exist
  • Passed the flag through service, business, action, and CLI command layers
  • Added CLI validation requiring --version when using --existing-version

Example Usage

$ chainloop att init --workflow sast --project my-project-2222 --replace --existing-version --version 11.11
ERR validation error: project version "11.11" not found
exit status 1

if the flag is not provided everything work as expected

$ chainloop att init --workflow sast --project my-project-2222 --replace --existing-version --version 11.11
┌───────────────────────────┬──────────────────────────────────────┐
│ Initialized At            │ 13 Nov 25 12:50 UTC                  │
├───────────────────────────┼──────────────────────────────────────┤
│ Attestation ID            │ a55db921-b6d9-4690-a634-8fe76dff172e │
│ Organization              │ john-owned                           │
│ Name                      │ sast                                 │
│ Project                   │ my-project-2222                      │
│ Version                   │ 11.11 (prerelease)                   │
│ Contract                  │ my-project-2222-sast (revision 1)    │
│ Policy violation strategy │ ADVISORY                             │
└───────────────────────────┴──────────────────────────────────────┘

and running it again makes it work

Resolves #2540

Add a new --existing-version flag to the attestation init command that
fails if the specified project version doesn't already exist in the
system. This is useful when running packaging tasks where you want to
ensure backpatches are associated with existing versions rather than
creating new ones.

Changes:
- Add require_existing_version field to AttestationServiceInitRequest proto
- Add validation in data layer to check version existence before workflow run creation
- Pass the flag through service, business, and action layers
- Add --existing-version CLI flag with validation
- Update license headers to 2024-2025

Resolves chainloop-dev#2540

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
@migmartri migmartri requested review from javirln and jiparis November 13, 2025 12:51
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
@migmartri migmartri marked this pull request as ready for review November 13, 2025 12:53
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
@migmartri migmartri merged commit 09d65fb into chainloop-dev:main Nov 13, 2025
13 checks passed
@migmartri migmartri deleted the 2540-version-exists branch November 13, 2025 13:26
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.

being able to check if a version exist during attestation init

2 participants