Cherry pick environment case regression fix 016b298 into v1.1.x