hcl: fix scenario where infinite loop happens