guard against empty input
limit the number of retries
[bamboo] Automated branch merge (from 1.12:239162eea4964793507cad55ac6cbbdcdb35a1d6)