Files
kevinveenbirkenbachandClaude Opus 5.5 a8b6707164 fix(deploy): never print the inventory file on an invalid application id
validate_application_ids printed the whole inventory file to stdout when
an --id was invalid, so a typo in ROLES put inline inventory variables,
credentials included, into CI and Semaphore task logs. The error now names
the invalid ids, their reasons and the inventory path only.

New test writes a real inventory file with a marker secret and asserts it
never reaches stdout; on the old code it fails with the marker printed
inside the BEGIN INVENTORY FILE block. Nothing in the repository parses
the removed dump. Reported by Store.

🎯 Fix: 96 %
💥 Break: 1 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 95
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 20:13:53 +00:00

29 lines
832 B
Python

from __future__ import annotations
import sys
def validate_application_ids(inventory: str, app_ids: list[str]) -> None:
"""Validate requested application IDs using ValidDeployId."""
if not app_ids:
return
from utils.roles.validation.deploy_id import ValidDeployId
validator = ValidDeployId()
invalid = validator.validate(inventory, app_ids)
if not invalid:
return
print(f"\n[ERROR] Some application_ids are invalid for inventory {inventory}:\n")
for app_id, status in invalid.items():
reasons = []
if not status.get("in_roles", True):
reasons.append("not defined as a role")
if not status.get("in_inventory", True):
reasons.append("not present in inventory")
print(f" - {app_id}: {', '.join(reasons)}")
sys.exit(1)