Skip to content

Commit 5bff241

Browse files
Yhoornemanclaude
andcommitted
feat: require --description when using --apply
A correction created with --apply must now carry a non-blank description; dry-run previews stay lenient. The help text notes the requirement and a test covers the abort path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b2c0761 commit 5bff241

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/datadog_slo_overrides_cli/datadog_slo_overrides_cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,8 @@ def build_config(
692692

693693
correction = None
694694
if apply:
695+
if not description.strip():
696+
sys.exit('error: --description is required with --apply')
695697
if start_epoch is None:
696698
sys.exit('error: --start is required with --apply')
697699
if end_epoch is None and not rrule:
@@ -849,7 +851,7 @@ def run(
849851
None,
850852
help=f'Correction category (config/default: {DEFAULT_CATEGORY}).',
851853
),
852-
description: str = typer.Option('', help='Free-text description stored on the correction.'),
854+
description: str = typer.Option('', help='Free-text description stored on the correction. Required with --apply.'),
853855
timezone: str = typer.Option(
854856
None,
855857
help=f'IANA timezone for start/end (config/default: {DEFAULT_TIMEZONE}).',

tests/test_datadog_slo_overrides_cli.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,26 @@ def test_build_config_dry_run_has_no_correction() -> None:
170170
assert cfg.required_tags == ['app:gitlab']
171171

172172

173+
def test_build_config_requires_description_with_apply() -> None:
174+
"""Applying without a (non-blank) description aborts, even with a valid window."""
175+
with pytest.raises(SystemExit):
176+
build_config(
177+
api_key='key',
178+
app_key='app',
179+
site='datadoghq.eu',
180+
timezone='UTC',
181+
category='Scheduled Maintenance',
182+
strategy=SKIP_IF_COVERED,
183+
description=' ',
184+
tags=['app:gitlab'],
185+
tags_query=None,
186+
start='2026-06-10T22:00',
187+
end='2026-06-10T23:00',
188+
rrule=None,
189+
apply=True,
190+
)
191+
192+
173193
def test_load_config_ignores_credentials(tmp_path: Path) -> None:
174194
"""Only non-secret keys are honoured; credential-like keys are dropped."""
175195
config = tmp_path / 'config.toml'

0 commit comments

Comments
 (0)