Check out https://github.com/yungsters/phabricator-scripts/commit/8b82f3e38979475418efae723047759a94178736, I fixed it there using a different method.