Skip to content

Conversation

@ste-el-bow
Copy link

@ste-el-bow ste-el-bow commented Oct 20, 2025

What does this PR do, and why?

Fixes error that causes zulip-term to crash at the start
When msg_btn_list is empty or focus_msg is invalid, ensure focus_msg is set to a valid index using max(0, len(msg_btn_list) - 1) instead of just len(msg_btn_list) - 1, which would cause an IndexError.

This prevents crashes when navigating to views with no messages.

External discussion & connections

  • Discussed in #zulip-terminal in topic
  • Fully fixes Crash at fresh start, index out of range #1589
  • Partially fixes issue #
  • Builds upon previous unmerged work in PR #
  • Is a follow-up to work in PR #
  • Requires merge of PR #
  • Merge will enable work on #

How did you test this?

  • Manually - Behavioral changes
  • Manually - Visual changes
  • Adapting existing automated tests
  • Adding automated tests for new behavior (or missing tests)
  • Existing automated tests should already cover this (only a refactor of tested code)

When msg_btn_list is empty or focus_msg is invalid, ensure focus_msg
is set to a valid index using max(0, len(msg_btn_list) - 1) instead of
just len(msg_btn_list) - 1, which would cause an IndexError.

This prevents crashes when navigating to views with no messages.
@zulipbot zulipbot added the size: S [Automatic label added by zulipbot] label Oct 20, 2025
@zulipbot
Copy link
Member

Hello @ste-el-bow, it seems like you have referenced #1589 in your pull request description, but you have not referenced them in your commit message description(s). Referencing an issue in a commit message automatically closes the corresponding issue when the commit is merged, which makes the issue tracker easier to manage.

Please run git commit --amend in your command line client to amend your commit message description with Fixes #1589..

An example of a correctly-formatted commit:

commit fabd5e450374c8dde65ec35f02140383940fe146
Author: zulipbot
Date:   Sat Mar 18 13:42:40 2017 -0700

    pull requests: Check PR commits reference when issue is referenced.

    Fixes #51.

To learn how to write a great commit message, please refer to our guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S [Automatic label added by zulipbot]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash at fresh start, index out of range

2 participants