Skip to content

ReadFile returns empty response and caches range on files with a trailing blank line #746

Closed

Description

@philippeback

Summary

ReadFile with range_start: "@000" and range_end: "000@" silently returns no content (and no error) on files ending with a trailing blank line (\n\n), and then blocks all subsequent ReadFile calls on that file with "Earlier contents still valid for 1 operation(s)".

Root Cause

In cecli/tools/read_file.py:

  1. lines = content.splitlines() includes the trailing empty line, so 000@ resolves to e_idx = len(lines) - 1.
  2. hashline_formatted(content, file_name=abs_path) produces hashed_lines with one fewer line (len(hashed_lines) == len(lines) - 1) when the file ends with a trailing blank line.
  3. ConversationService.get_files(coder).update_file_context(abs_path, start_line, end_line, auto_remove=False) runs before the bounds check.
  4. The bounds check e_idx < len(hashed_lines) evaluates to False, so model_response is skipped and nothing is added to new_context_details.
  5. Because the range was already recorded in ConversationService.get_files, every follow-up ReadFile call (even with explicit @L ranges) reports "Earlier contents still valid for 1 operation(s)" even though the model never received the file contents.

Reproduction

Call ReadFile with @000..000@ on any file ending with \n\n (e.g., "line1\nline2\nline3\n\n").

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions