Skip to content

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

Open

Description

@LeonardoLGDS

Problem

gh api ... -f [email protected] 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 [email protected]   # 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 "[email protected]" 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.

Activity

  1. cli-triage commented on Aug 20, 2026

    @cli-triage

    Thanks for the detailed write-up! No duplicates found for this. I'm suggesting the enhancement label since this is a clear, well-reasoned UX improvement request (warn when -f/--raw-field is given an @file value that resolves to an existing file, since -f doesn't read files unlike -F). A maintainer can weigh in on scope/implementation details.

    Generated by Issue Triage (skills-driven) · auto · 15.6 AIC · ⌖ 0.582 AIC · ⊞ 9.7K · ◷

  2. added
    enhancement
    on Aug 26, 2026
  3. removed
    needs-triage
    on Aug 26, 2026
  4. github-actions commented on Aug 26, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  5. mmustafasenoglu commented on Sep 16, 2026

    @mmustafasenoglu

    Hi, I'd like to work on this one. Per CONTRIBUTING I wanted to check first: would you accept the non-breaking direction suggested here (stderr warning only when a -f value starts with @ and the remainder names an existing file, plus a short help-text note)? @cli/code-reviewers, happy to shape it to whatever acceptance criteria you'd prefer. Thanks!

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

    enhancementstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions