Skip to content

[Bug] gh gist edit truncates large gist file and risks data loss #11739

@0xdevalias

Description

@0xdevalias

Describe the bug

When editing a large gist (secret, so can't share directly) containing a single .md file (~1.6 MB, ~38,072 lines, ~1.7M bytes), using gh gist edit does not load the entire file content. The file is truncated to about 900K bytes (17,000 lines), instead of loading the full content.

This presents a risk: If a user edits and saves, the truncated file will overwrite the gist, resulting in data loss.

Affected version

⇒ gh version
gh version 2.67.0 (2025-02-11)
https://github.com/cli/cli/releases/tag/v2.67.0
  • Platform: macOS

Steps to reproduce the behavior

  1. Have a gist with a large file (e.g., 1.6 MB .md file, ~38,000 lines).
  2. Run gh gist edit <gist-id> (with any editor).
  3. Observe that the file content is cut off (e.g., only 900K of 1.6M bytes loaded).
  4. (Optional) Save the file, which would (presumably) overwrite the gist with a truncated version.

Expected vs actual behavior

Expected:

  • gh gist edit should load and allow editing of the entire file, regardless of size, or should display a clear error message if the file is too large to edit safely.

Actual:

  • The file is silently truncated. No warning or error is given. Risk of accidental data loss if saved (presumably).

Logs

⇒ gh gist clone <gist-id> && cd <gist-id>

⇒ du -sh foo.md
1.6M  foo.md

⇒ cat foo.md | wc -l
38072

⇒ cat foo.md | wc -c
1685200

⇒ EDITOR=cat gh gist edit <gist-id> | wc -l
17000

⇒ EDITOR=cat gh gist edit <gist-id> | wc -c
921600

⇒ EDITOR=cat gh gist edit <gist-id> | wc -c | numfmt --to=iec
900K

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggh-gistrelating to the gh gist commandhelp wantedContributions welcomep3Affects a small number of users or is largely cosmetic

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions