fix: warn when automation-profile add --update given but no existing profile

When the --update flag is provided to agents automation-profile add but no existing profile with the given name exists, the command now emits a clear warning message to the user before proceeding to create the new profile. This prevents silent no-ops and helps users understand that --update had no effect.

Added a new BDD scenario to automation_profile_cli.feature to verify the warning is displayed when --update is given for a non-existent profile.

ISSUES CLOSED: #8830
This commit is contained in:
Test User
2026-04-19 02:17:55 +00:00
committed by Forgejo
parent ecf9710369
commit bdd3348f46
2 changed files with 13 additions and 0 deletions
+7
View File
@@ -20,6 +20,13 @@ Feature: Automation Profile CLI commands
Then the automation-profile add should succeed
And the automation-profile output should contain "Updated"
Scenario: Add profile with --update when profile does not exist warns and creates
Given a valid automation profile config YAML file
When I run automation-profile add with --config and --update
Then the automation-profile add should succeed
And the automation-profile output should contain "Warning"
And the automation-profile output should contain "Profile Added"
Scenario: Add profile conflict without --update
Given a valid automation profile config YAML file
And the custom profile "acme/strict" already exists
@@ -236,6 +236,12 @@ def add_profile(
)
raise typer.Abort()
if update and not existing:
console.print(
f"[yellow]Warning:[/yellow] Profile '{name}' does not exist. "
f"Creating new profile (--update flag has no effect)."
)
if update and existing:
profile = service.update_profile(name, config_data)
title = "Profile Updated"