MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / remove_dependency

Function remove_dependency

server/routers/features.py:644–676  ·  view source on GitHub ↗

Remove a dependency from a feature.

(project_name: str, feature_id: int, dep_id: int)

Source from the content-addressed store, hash-verified

642
643@router.delete("/{feature_id}/dependencies/{dep_id}")
644async def remove_dependency(project_name: str, feature_id: int, dep_id: int):
645 """Remove a dependency from a feature."""
646 project_name = validate_project_name(project_name)
647 project_dir = _get_project_path(project_name)
648
649 if not project_dir:
650 raise HTTPException(status_code=404, detail=f"Project '{project_name}' not found in registry")
651
652 if not project_dir.exists():
653 raise HTTPException(status_code=404, detail="Project directory not found")
654
655 _, Feature = _get_db_classes()
656
657 try:
658 with get_db_session(project_dir) as session:
659 feature = session.query(Feature).filter(Feature.id == feature_id).first()
660 if not feature:
661 raise HTTPException(status_code=404, detail=f"Feature {feature_id} not found")
662
663 current_deps = feature.dependencies or []
664 if dep_id not in current_deps:
665 raise HTTPException(status_code=400, detail="Dependency does not exist")
666
667 current_deps.remove(dep_id)
668 feature.dependencies = current_deps if current_deps else None
669 session.commit()
670
671 return {"success": True, "feature_id": feature_id, "dependencies": feature.dependencies or []}
672 except HTTPException:
673 raise
674 except Exception:
675 logger.exception("Failed to remove dependency")
676 raise HTTPException(status_code=500, detail="Failed to remove dependency")
677
678
679@router.put("/{feature_id}/dependencies")

Callers

nothing calls this directly

Calls 3

_get_db_classesFunction · 0.85
get_db_sessionFunction · 0.85
validate_project_nameFunction · 0.70

Tested by

no test coverage detected