[backend] refactor path handling in set_building