Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

kv-store-entry create --dir never closes uploaded files and retries with an empty body

オープン
#1,942 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
cli

調査の方向性

Start with ProcessDir in pkg/commands/kvstoreentry/create.go and trace how the opened file is passed through fastly.FileLengthReader into the upload and retry. The issue describes two regression checks against the mock API: verify the file is closed after the command returns, and verify a retry sends the full FOO\n body. Done when both checks pass.

索引モデルが issue の本文から書いたものです。

説明

What happens

fastly kv-store-entry create --store-id <id> --dir <path> opens every file in the directory with os.Open in ProcessDir (pkg/commands/kvstoreentry/create.go) and never closes it. The file is wrapped in fastly.FileLengthReader, which is not an io.Closer, so the HTTP client does not close it either. Each upload keeps its descriptor open until the garbage collector happens to finalize the *os.File. On a large directory this can run into the per process open file limit (256 by default on macOS).

The same goroutine retries the upload once when the error contains net/http: cannot rewind body after connection loss. The retry passes the same reader again, but the failed attempt has already read from the file, so the retry sends a short or empty body while the request still declares the full length. The retry cannot succeed.

What should happen

Each file should be closed once its upload is done, and the file should be rewound to the start before the retry so the full content is sent again.

Minimal repro

Two tests against the mock API show both problems:

  1. Capture InsertKVStoreKeyInput.Body in InsertKVStoreKeyFn, run kv-store-entry create --store-id x --dir testdata/example, then read from the captured body after the command returns. The read returns EOF instead of os.ErrClosed, so the file is still open.
  2. Make the first InsertKVStoreKeyFn call read the body and return errors.New("net/http: cannot rewind body after connection loss"), and make the second call check the body. The second call receives "" instead of the file content "FOO\n".

Root cause

ProcessDir has no f.Close() for the file it opens, and the retry branch calls insertKey(opts) again without seeking the file back to offset 0.

I have a fix with a regression test ready and can open a PR if you assign this to me.

主要言語
Go
スター
164
フォーク
81
平均マージ
1日 3時間
マージ済み PR(30日)
23

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fastly/cli のほかの issue

fastly/cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。