Spaces:
Runtime error
Runtime error
Download dev-agent/app/validators/conflict_validator.py from BeastGokul/MVP: direct link, hf CLI and curl.
- Browser
- Download file 2.49 kB
-
https://huggingface.co/spaces/BeastGokul/MVP/resolve/main/dev-agent/app/validators/conflict_validator.py
- Command line
-
hf download hf://spaces/BeastGokul/MVP/dev-agent/app/validators/conflict_validator.py
-
curl -L -o conflict_validator.py https://huggingface.co/spaces/BeastGokul/MVP/resolve/main/dev-agent/app/validators/conflict_validator.py
2.49 kB
| from ..schemas.agent_spec import AgentSpec, TriggerType | |
| from ..schemas.conversation import ValidationError, ValidationResult | |
| class ConflictValidator: | |
| def validate(self, spec: AgentSpec) -> ValidationResult: | |
| errors = [] | |
| trigger = spec.trigger | |
| config = trigger.config or {} | |
| # 1. Conflict: manual trigger should not have event/schedule configurations | |
| if trigger.type == TriggerType.MANUAL: | |
| schedule_or_event_keys = {"cron", "interval", "schedule", "event", "webhook", "path"} | |
| conflicting = schedule_or_event_keys.intersection(config.keys()) | |
| if conflicting: | |
| errors.append(ValidationError( | |
| code="TRIGGER_CONFLICT", | |
| message=f"Manual trigger config cannot contain scheduling or event configurations: {list(conflicting)}", | |
| path="trigger.config" | |
| )) | |
| # 2. Conflict: schedule trigger requires schedule properties, not webhook/event | |
| elif trigger.type == TriggerType.SCHEDULE: | |
| if not any(k in config for k in ("cron", "interval", "interval_seconds")): | |
| errors.append(ValidationError( | |
| code="TRIGGER_CONFLICT", | |
| message="Schedule trigger config requires 'cron', 'interval', or 'interval_seconds'", | |
| path="trigger.config" | |
| )) | |
| event_keys = {"event", "webhook", "path"} | |
| conflicting = event_keys.intersection(config.keys()) | |
| if conflicting: | |
| errors.append(ValidationError( | |
| code="TRIGGER_CONFLICT", | |
| message=f"Schedule trigger config cannot contain event or webhook configurations: {list(conflicting)}", | |
| path="trigger.config" | |
| )) | |
| # 3. Conflict: webhook trigger should not contain scheduling properties | |
| elif trigger.type == TriggerType.WEBHOOK: | |
| schedule_keys = {"cron", "interval", "interval_seconds"} | |
| conflicting = schedule_keys.intersection(config.keys()) | |
| if conflicting: | |
| errors.append(ValidationError( | |
| code="TRIGGER_CONFLICT", | |
| message=f"Webhook trigger config cannot contain scheduling configurations: {list(conflicting)}", | |
| path="trigger.config" | |
| )) | |
| return ValidationResult(valid=len(errors) == 0, errors=errors) | |