Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

filesystem: read_text_file tail returns one line too few when the file ends with a newline

Aperta
#5,187 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend

Direzione di ricerca

Start with tailFile in src/filesystem/lib.ts and the trailing newline test in src/filesystem/__tests__/server-tools.test.ts; trace how the decoded tail is split, including LF, CRLF, and the chunk boundary. Update the test to capture the expected behavior, then verify tail: 1 and tail: 2 return the final lines without counting a trailing newline as an extra line.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug server-filesystem v2
Problem

tailFile in src/filesystem/lib.ts splits the decoded tail on \n and keeps the last N segments. For a file that ends with a newline, the empty segment after the final \n counts as one of the N lines: tail: 1 on "a\nb\nc\n" returns an empty string, and tail: 2 returns only c. The test in src/filesystem/__tests__/server-tools.test.ts that counts the trailing newline as a line pins this today. head does not have the problem.

Expected

A final newline ends the last line and is not counted as an extra empty line, for LF and CRLF files and across the chunk boundary tailFile reads in. The pinning test changes with the fix.

Prior work
  • #4674 by @jstar0
  • #4643 by @teddiesloco

The PR(s) above targeted the pre-refactor code and are closed as part of the backlog triage in #4875; this issue is where the work continues, with the PR(s) as a prototype. Thank you to their authors.

Lingua principale
TypeScript
Stelle
91.4k
Fork
11.8k
Merge medio
6h 37m
PR unite (30g)
147

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/servers

Tutte le issue di modelcontextprotocol/servers

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.