Skip to content

Commit 8a4dbaf

Browse files
committed
fix: check disabled by definition.id, reload registry after rollback, reuse _ID_PATTERN
- Check disabled status by both source arg and loaded definition.id so file-path invocations of disabled workflows are also blocked - Reload registry in-memory state from disk after snapshot restore so subsequent updates in the same run don't write back stale data - Replace duplicated ID regex with shared _ID_PATTERN from engine
1 parent f18e5a3 commit 8a4dbaf

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4687,6 +4687,14 @@ def workflow_run(
46874687
console.print(f"[red]Error:[/red] Invalid workflow: {exc}")
46884688
raise typer.Exit(1)
46894689

4690+
# Also check by loaded definition ID (covers file-path invocations)
4691+
if definition.id and definition.id != source:
4692+
wf_meta_by_id = wf_registry.get(definition.id)
4693+
if isinstance(wf_meta_by_id, dict) and not wf_meta_by_id.get("enabled", True):
4694+
console.print(f"[red]Error:[/red] Workflow '{definition.id}' is disabled")
4695+
console.print(f"\nTo re-enable: specify workflow enable {definition.id}")
4696+
raise typer.Exit(1)
4697+
46904698
# Validate
46914699
errors = engine.validate(definition)
46924700
if errors:
@@ -5097,8 +5105,8 @@ def _validate_and_install_local(yaml_path: Path, source_label: str) -> None:
50975105

50985106
workflow_dir = workflows_dir / source
50995107
# Validate workflow ID format and path safety
5100-
import re as _re
5101-
if not _re.match(r"^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$", source):
5108+
from .workflows.engine import _ID_PATTERN as _WORKFLOW_ID_PATTERN
5109+
if not _WORKFLOW_ID_PATTERN.fullmatch(source):
51025110
console.print(f"[red]Error:[/red] Invalid workflow ID: {source!r}")
51035111
raise typer.Exit(1)
51045112
try:
@@ -5412,8 +5420,8 @@ def workflow_update(
54125420

54135421
wf_dir = workflows_dir / wf_id
54145422
# Validate workflow ID format and path safety
5415-
import re as _re
5416-
if not _re.match(r"^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$", wf_id):
5423+
from .workflows.engine import _ID_PATTERN as _WORKFLOW_ID_PATTERN
5424+
if not _WORKFLOW_ID_PATTERN.fullmatch(wf_id):
54175425
console.print(f"⚠ {wf_id}: Invalid workflow ID format (skipping)")
54185426
continue
54195427
try:
@@ -5487,6 +5495,8 @@ def workflow_update(
54875495
except OSError:
54885496
pass
54895497
registry_snapshot = None
5498+
# Reload in-memory state from restored file
5499+
registry.data = registry._load()
54905500
# Restore workflow from backup
54915501
if backup_dir and backup_dir.exists():
54925502
if wf_dir.exists():

0 commit comments

Comments
 (0)