am-project: Avoid a crash when adding a target to an invalid group