Skip to content

gh api: warn when -f value starts with @ and names an existing file #14199

Description

@LeonardoLGDS

Problem

gh api ... -f body=@draft.md sends the literal string @draft.md as the value and exits 0. The file is not read.

$ printf 'hello' > draft.md
$ gh api repos/o/r/issues/1/comments -f body=@draft.md   # creates a comment whose body is literally "@draft.md"

-F/--field reads the file (help: "use @<path> or @- to read value from file or stdin"), and --body-file reads files explicitly for PR/issue bodies, but the lowercase flag differs from the file-reading one by a single character and fails silently. In scripted or agent-driven workflows the result is a literal @path string posted to a public thread, logged as success by the caller.

Suggestion (non-breaking)

When a -f/--raw-field value starts with @, print a stderr warning, but only when the remainder names an existing file:

warning: -f value "body=@draft.md" starts with "@"; -f/--raw-field sends values literally, did you mean -F/--field?

Restricting the warning to values that resolve to an existing file avoids false positives for ordinary @mention-style values. Optionally add a matching note in the help text under -f/--raw-field (file reading is currently documented only under -F/--field).

Happy to adjust scope; this is a UX suggestion, not a behavior change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions