fix: list index out of range (#37890)
* fix: list index out of range
* fix: solve linter test failing
(cherry picked from commit e5bc8fccb17d96df81e10d3b4b565b430c1b5374)
Co-authored-by: viralkansodiya15 <98073516+viralpatel15@users.noreply.github.com>