Skip to content

Getting "template not found" errors for gh issue create --template=... #9327

Closed

Description

@PhilippFeO

Describe the bug

Running gh issue create ignores my templates in .github/, fi. .github/ISSUE_TEMPLATE.md. gh issue create -T .github/ISSUE_TEMPLATE.md or with --tempalate yields "no template found"

$ gh --version
gh version 2.52.0 (2024-06-24)
https://github.com/cli/cli/releases/tag/v2.52.0

Steps to reproduce the behavior

  1. Place issue template generated via GitHub in ./github/ISSUE_TEMPLATE.md
    2a. gh issue create
    3a. No template used for issue creation

2b. gh issue create -T .github/ISSUE_TEMPLATE.md
3b. Follow steps
4b. Result:

$ gh issue create -T .github/ISSUE_TEMPLATE.md
Creating issue in PhilippFeO/nvim
? Title Test
X operation failed. To restore: gh issue create --recover /tmp/gh2397437919.json
no templates found
$ gh issue create -T ISSUE_TEMPLATE.md
Creating issue in PhilippFeO/nvim
? Title TEST
X operation failed. To restore: gh issue create --recover /tmp/gh2679218676.json
no templates found
$ ls .github
ISSUE_TEMPLATE.md  vorlage_1.md

Expected vs actual behavior

I expected that my template is used in some way or the other.

Logs

Where can I find the logs? 😅


Maybe related to #9220

Activity

  1. williammartin commented on Jul 18, 2024

    @williammartin
    Member

    Where can I find the logs? 😅

    Well your terminal output is part of it, and running the commands with GH_DEBUG=api is another.

    When I run with GH_DEBUG=api I can see that your repository returned no templates:

    * Request at 2024-07-18 12:12:37.6718 +0200 CEST m=+4.525302501
    * Request to https://api.github.com/graphql
    > POST /graphql HTTP/1.1
    > Host: api.github.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: token ████████████████████
    > Content-Length: 178
    > Content-Type: application/json
    > Graphql-Features: merge_queue
    > Time-Zone: Europe/Amsterdam
    > User-Agent: GitHub CLI 2.50.0
    
    GraphQL query:
    query IssueTemplates($name:String!$owner:String!){repository(owner: $owner, name: $name){issueTemplates{name,body}}}
    GraphQL variables: {"name":"nvim","owner":"PhilippFeO"}
    
    < HTTP/2.0 200 OK
    < Access-Control-Allow-Origin: *
    < Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
    < Content-Security-Policy: default-src 'none'
    < Content-Type: application/json; charset=utf-8
    < Date: Thu, 18 Jul 2024 10:12:37 GMT
    < Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
    < Server: GitHub.com
    < Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
    < Vary: Accept-Encoding, Accept, X-Requested-With
    < X-Accepted-Oauth-Scopes: repo
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: deny
    < X-Github-Media-Type: github.v4; param=merge-info-preview.nebula-preview; format=json
    < X-Github-Request-Id: DB86:1B4C5C:399782:3A223E:6698EA91
    < X-Oauth-Client-Id: 178c6fc778ccc68e1d6a
    < X-Oauth-Scopes: delete_repo, gist, read:org, repo, workflow
    < X-Ratelimit-Limit: 5000
    < X-Ratelimit-Remaining: 5000
    < X-Ratelimit-Reset: 1721300560
    < X-Ratelimit-Resource: graphql
    < X-Ratelimit-Used: 30
    < X-Xss-Protection: 0
    
    {
      "data": {
        "repository": {
          "issueTemplates": []
        }
      }
    }
    

    When I look at your repository I don't see a .github folder: https://github.com/PhilippFeO/nvim

    Is it possible that the issue template is only in your local git repository? I could understand how that might be confusing.

  2. added
    more-info-neededMore info needed from user/contributor
    gh-releaserelating to the gh release command
    and removed on Jul 18, 2024
  3. PhilippFeO commented on Jul 18, 2024

    @PhilippFeO
    Author

    Is it possible that the issue template is only in your local git repository?

    I have a branch for testing the feature: https://github.com/PhilippFeO/nvim/tree/octo-test

    But am I write in assuming that this feature only works if the folder and files were commited?


    Can I share the output of gh issue create with GH_DEBUG=api without exposing any secrets? The logs are quite long and I am no web dev expert 😅

  4. williammartin commented on Jul 18, 2024

    @williammartin
    Member

    Can I share the output of gh issue create with GH_DEBUG=api without exposing any secrets?

    There are no secrets in there but for example, you may have confidential information like company repositories. Doesn't look like it in your case.

    But am I write in assuming that this feature only works if the folder and files were commited?

    Ah yes, unfortunately issue templates are based on the default branch, in your case main.

  5. PhilippFeO commented on Jul 18, 2024

    @PhilippFeO
    Author

    Ah yes, unfortunately issue templates are based on the default branch, in your case main.

    Haven't seen this piece in the docs 😅 But it doesn't make a difference. I moved .github into main, commited, pushed but still 'no template found'. :(


    Logs, ie GH_DEBUG=api:

      $ gh issue create -T .github/ISSUE_TEMPLATE.md 
    [git remote -v]
    [git config --get-regexp ^remote\..*\.gh-resolved$]
    * Request at 2024-07-18 12:45:52.816733298 +0200 CEST m=+0.060428049
    * Request to https://api.github.com/graphql
    > POST /graphql HTTP/1.1
    > Host: api.github.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: token ████████████████████
    > Content-Length: 389
    > Content-Type: application/json; charset=utf-8
    > Graphql-Features: merge_queue
    > Time-Zone: Europe/Berlin
    > User-Agent: GitHub CLI 2.52.0
    
    GraphQL query:
    fragment repo on Repository {
        id
        name
        owner { login }
        viewerPermission
        defaultBranchRef {
          name
        }
        isPrivate
      }
      query RepositoryNetwork {
        viewer { login }
        
        repo_000: repository(owner: "PhilippFeO", name: "nvim") {
          ...repo
          parent {
            ...repo
          }
        }
        
      }
    GraphQL variables: null
    
    < HTTP/2.0 200 OK
    < Access-Control-Allow-Origin: *
    < Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
    < Content-Security-Policy: default-src 'none'
    < Content-Type: application/json; charset=utf-8
    < Date: Thu, 18 Jul 2024 10:45:53 GMT
    < Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
    < Server: GitHub.com
    < Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
    < Vary: Accept-Encoding, Accept, X-Requested-With
    < X-Accepted-Oauth-Scopes: repo
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: deny
    < X-Github-Media-Type: github.v4; param=merge-info-preview.nebula-preview; format=json
    < X-Github-Request-Id: 1D80:D2D34:5D4A0B:5E2241:6698F260
    < X-Oauth-Client-Id: 178c6fc778ccc68e1d6a
    < X-Oauth-Scopes: admin:public_key, gist, read:org, read:project, repo
    < X-Ratelimit-Limit: 5000
    < X-Ratelimit-Remaining: 4976
    < X-Ratelimit-Reset: 1721302046
    < X-Ratelimit-Resource: graphql
    < X-Ratelimit-Used: 24
    < X-Xss-Protection: 0
    
    {
      "data": {
        "viewer": {
          "login": "PhilippFeO"
        },
        "repo_000": {
          "id": "R_kgDOK1PFbA",
          "name": "nvim",
          "owner": {
            "login": "PhilippFeO"
          },
          "viewerPermission": "ADMIN",
          "defaultBranchRef": {
            "name": "main"
          },
          "isPrivate": false,
          "parent": null
        }
      }
    }
    
    * Request took 304.602458ms
    
    Creating issue in PhilippFeO/nvim
    
    * Request at 2024-07-18 12:45:53.122853782 +0200 CEST m=+0.366548611
    * Request to https://api.github.com/graphql
    > POST /graphql HTTP/1.1
    > Host: api.github.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: token ████████████████████
    > Content-Length: 516
    > Content-Type: application/json; charset=utf-8
    > Graphql-Features: merge_queue
    > Time-Zone: Europe/Berlin
    > User-Agent: GitHub CLI 2.52.0
    
    GraphQL query:
    fragment repo on Repository {
        id
        name
        owner { login }
        hasIssuesEnabled
        description
        hasWikiEnabled
        viewerPermission
        defaultBranchRef {
          name
        }
      }
    
      query RepositoryInfo($owner: String!, $name: String!) {
        repository(owner: $owner, name: $name) {
          ...repo
          parent {
            ...repo
          }
          mergeCommitAllowed
          rebaseMergeAllowed
          squashMergeAllowed
        }
      }
    GraphQL variables: {"name":"nvim","owner":"PhilippFeO"}
    
    < HTTP/2.0 200 OK
    < Access-Control-Allow-Origin: *
    < Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
    < Content-Security-Policy: default-src 'none'
    < Content-Type: application/json; charset=utf-8
    < Date: Thu, 18 Jul 2024 10:45:53 GMT
    < Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
    < Server: GitHub.com
    < Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
    < Vary: Accept-Encoding, Accept, X-Requested-With
    < X-Accepted-Oauth-Scopes: repo
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: deny
    < X-Github-Media-Type: github.v4; param=merge-info-preview.nebula-preview; format=json
    < X-Github-Request-Id: 1D80:D2D34:5D4B1C:5E2379:6698F261
    < X-Oauth-Client-Id: 178c6fc778ccc68e1d6a
    < X-Oauth-Scopes: admin:public_key, gist, read:org, read:project, repo
    < X-Ratelimit-Limit: 5000
    < X-Ratelimit-Remaining: 4975
    < X-Ratelimit-Reset: 1721302046
    < X-Ratelimit-Resource: graphql
    < X-Ratelimit-Used: 25
    < X-Xss-Protection: 0
    
    {
      "data": {
        "repository": {
          "id": "R_kgDOK1PFbA",
          "name": "nvim",
          "owner": {
            "login": "PhilippFeO"
          },
          "hasIssuesEnabled": true,
          "description": "My Neovim setup.",
          "hasWikiEnabled": true,
          "viewerPermission": "ADMIN",
          "defaultBranchRef": {
            "name": "main"
          },
          "parent": null,
          "mergeCommitAllowed": true,
          "rebaseMergeAllowed": true,
          "squashMergeAllowed": true
        }
      }
    }
    
    * Request took 305.313889ms
    ? Title Test
    * Request at 2024-07-18 12:45:59.160889751 +0200 CEST m=+6.404584587
    * Request to https://api.github.com/graphql
    > POST /graphql HTTP/1.1
    > Host: api.github.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: token ████████████████████
    > Content-Length: 178
    > Content-Type: application/json
    > Graphql-Features: merge_queue
    > Time-Zone: Europe/Berlin
    > User-Agent: GitHub CLI 2.52.0
    
    GraphQL query:
    query IssueTemplates($name:String!$owner:String!){repository(owner: $owner, name: $name){issueTemplates{name,body}}}
    GraphQL variables: {"name":"nvim","owner":"PhilippFeO"}
    
    < HTTP/2.0 200 OK
    < Access-Control-Allow-Origin: *
    < Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
    < Content-Security-Policy: default-src 'none'
    < Content-Type: application/json; charset=utf-8
    < Date: Thu, 18 Jul 2024 10:45:59 GMT
    < Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
    < Server: GitHub.com
    < Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
    < Vary: Accept-Encoding, Accept, X-Requested-With
    < X-Accepted-Oauth-Scopes: repo
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: deny
    < X-Github-Media-Type: github.v4; param=merge-info-preview.nebula-preview; format=json
    < X-Github-Request-Id: 1D80:D2D34:5D6664:5E3EDC:6698F261
    < X-Oauth-Client-Id: 178c6fc778ccc68e1d6a
    < X-Oauth-Scopes: admin:public_key, gist, read:org, read:project, repo
    < X-Ratelimit-Limit: 5000
    < X-Ratelimit-Remaining: 4974
    < X-Ratelimit-Reset: 1721302046
    < X-Ratelimit-Resource: graphql
    < X-Ratelimit-Used: 26
    < X-Xss-Protection: 0
    
    {
      "data": {
        "repository": {
          "issueTemplates": []
        }
      }
    }
    
    * Request took 309.991903ms
    [git rev-parse --show-toplevel]
    
    X operation failed. To restore: gh issue create --recover /tmp/gh1963654485.json
    
    no templates found
    
  6. williammartin commented on Jul 18, 2024

    @williammartin
    Member

    https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates

    Issue templates are stored on the repository's default branch, in a hidden .github/ISSUE_TEMPLATE directory. If you create a template in another branch, it will not be available for collaborators to use.

    You must create templates on the repository's default branch. Templates created in other branches are not available for collaborators to use.


    Not to worry though, definitely an easy mistake to make. I don't think there's anything we can do to help you here unfortunately. I suppose we could say something like "no templates found, are you sure they are on the default branch?".

  7. PhilippFeO commented on Jul 18, 2024

    @PhilippFeO
    Author

    Embarrassing, I didn't catch both sentences! 🙈 I am sorry!


    Sad, that it just doesn't work on my machine :/ Out of curiosity: Do you have any assumptions which might be too technical for a discussion via GitHub? You can't debug everything here.

  8. williammartin commented on Jul 18, 2024

    @williammartin
    Member

    Sad, that it just doesn't work on my machine :/

    We could consider having gh look at your currently open repo in some cases. For example, if the template was used to populate your local editor we could probably do that, but it wouldn't work with --template --web obviously, which might be confusing. I don't know whether we would accept this as a feature or not but I'd be open to the discussion.

    Out of curiosity: Do you have any assumptions which might be too technical for a discussion via GitHub? You can't debug everything here.

    I'm sorry, I don't understand the question!

  9. PhilippFeO commented on Jul 18, 2024

    @PhilippFeO
    Author

    I dont plan using --web on any occasion because I control gh via a Neovim plugin – but other people might.

    We could consider having gh look at your currently open repo in some cases. For example, if the template was used to populate your local editor we could probably do that [...]

    Isn't it too late then? Sounds like a pot look up to me (maybe don't getting your point).


    When I write software and it doesn't work for a user, it is unsatisfying to not be able to help him but it is even more unsatisfying not to know why it doesn't work. Since you can debug more efficiently face to face with the machine, you have more capabilities to find the bug – means are limited on GitHub. So, I wonder if you have something in mind you would do/check in case my machine would be under your control. It is a quite theoretical definition.

  10. williammartin commented on Jul 18, 2024

    @williammartin
    Member

    Isn't it too late then? Sounds like a pot look up to me (maybe don't getting your point).

    ➜ gh issue create
    
    Creating issue in cli/cli
    
    ? Title Template Demo
    ? Choose a template  [Use arrows to move, type to filter]
    > 🐛 Bug report
      📣 Feedback
      ⭐ Submit a request
      Open a blank issue
    

    At this point, the template is loaded into your editor.

    These templates are pulled from the API, as you've seen above. My suggestion is that maybe they could also look at files in your local git repo, if you are in one. I don't think it's a great idea because I think it's probably a lot more confusing than what currently exists (for example, what if you have a modified local template, should we use that one, or the remote one).


    So, I wonder if you have something in mind you would do/check in case my machine would be under your control. It is a quite theoretical definition.

    Gotcha. In this particular case I didn't need to do much because your repo was public so I could run the same command you did with GH_DEBUG=api, see that the IssueTemplates node was empty, and then check your repo to confirm.

    But other times of course there are challenges, the most challenging of which are around different platforms and configurations, particularly when they are unusual.

  11. PhilippFeO commented on Jul 18, 2024

    @PhilippFeO
    Author

    These templates are pulled from the API, as you've seen above. My suggestion is that maybe they could also look at files in your local git repo, if you are in one. I don't think it's a great idea because I think it's probably a lot more confusing than what currently exists (for example, what if you have a modified local template, should we use that one, or the remote one).

    I hadn't this in mind. I thought gh looks at my local folder. But it makes sense to pull them because the templates have to work on github.com as well. Good to know, thank you!

    Isn't it possible to do it like this:

    1. Pull from API
    2. No results (as seen by my repo): look at the local .github folder

    In my case, having local issue templates is more than sufficient but I guess gh also aims to larger Open Source projects which have to use defined templates to keep track. Users with their own templates create confusion – then it doesn't make sense.

    Then, the questions shifts to "How do we control the procedure?" because 2. has to be optional. (Personally, I am a friend of config files.)

  12. williammartin commented on Jul 18, 2024

    @williammartin
    Member

    Isn't it possible to do it like this:

    It's possible but there are some weird behaviours that can crop up. For example, let's say you are working on a repository that has no templates, then one of your collaborators adds one, now your local set up is broken in a surprising way that you have no visibility into.

    I think that if you want to have a template locally, that's probably a distinct thing from GitHub Templates and you should use gh issue create --body-file <path to file> --editor which will prefill your editor with the contents of that file. This was just released yesterday, so you'll need to upgrade. Try it out and let me know if it works the way you expect.

  13. PhilippFeO commented on Jul 18, 2024

    @PhilippFeO
    Author

    I'll let you know it tomorrow! :)

  14. PhilippFeO commented on Jul 19, 2024

    @PhilippFeO
    Author

    It works! Thank you! 🚀

  15. williammartin commented on Jul 19, 2024

    @williammartin
    Member

    Great, thanks! I'm gonna close this now.

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

    bugSomething isn't workinggh-releaserelating to the gh release commandmore-info-neededMore info needed from user/contributor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions