Skip to content

gh gist edit <gist-url> command not working successfully with HTTP status code 422 #7630

Description

@Petesta

Describe the bug

A clear and concise description of what the bug is. Include version by typing gh --version.
When running gh --version I have the following output.

gh version 2.31.0 (2023-06-20)
https://github.com/cli/cli/releases/tag/v2.31.0

Steps to reproduce the behavior

  1. This occurs when running gh gist edit <gist-url> or gh gist edit <gist-url> --filename <filename>
  2. The output from the above command.
$> gh gist edit <gist-url>
HTTP 422: Invalid request. (https://api.github.com/gists/<gist-id>)

"public", "updated_at" are not permitted keys.
"language", "type" are not permitted keys.

Expected vs actual behavior

I expect this to work successfully when editing a gist. I recently installed gh yesterday and it was working successfully then too.

I've confirmed I have a valid access token and created a new one too. I can create gists from the command line with gh gist create <filename> and run other commands successfully.

$> gh gist create <filename>
- Creating gist <filename>
✓ Created secret gist <filename>
https://gist.github.com/<username>/<gist-url>

My value for EDITOR is vim.

Activity

  1. alex-petrov-vt commented on Jun 27, 2023

    @alex-petrov-vt
    Contributor

    Looks like gist edit command is sending a POST request:

    err = apiClient.REST(hostname, "POST", path, requestBody, &result)

    but the API docs say that the edit should be a PATCH: https://docs.github.com/en/rest/gists/gists?apiVersion=2022-11-28#update-a-gist

    Not sure if the API changed or why there was a difference in the first place.

  2. williammartin commented on Jun 27, 2023

    @williammartin
    Member

    This is reproducible for me, and it doesn't seem to be a change on our end since this is reproducible several versions back:

    ➜  cli git:(v2.25.0) ✗ EDITOR=lvim ~/workspace/cli/bin/gh gist edit https://gist.github.com/williammartin/c7970e50dcd30139d6b7434714ee79a5
    HTTP 422: Invalid request. (https://api.github.com/gists/c7970e50dcd30139d6b7434714ee79a5)
    
    "public", "updated_at" are not permitted keys.
    "type" is not a permitted key.

    It seems likely that this is a platform change so I'm going to add that label and begin investigating.

    but the API docs say that the edit should be a PATCH: https://docs.github.com/en/rest/gists/gists?apiVersion=2022-11-28#update-a-gist

    That's a good callout. I checked internally and this endpoint is actually implemented for both POST and PATCH so I guess it has always worked and that's a bit of a red herring.

  3. added
    platformProblems with the GitHub platform rather than the CLI client
    on Jun 27, 2023
  4. williammartin commented on Jun 27, 2023

    @williammartin
    Member

    I can confirm that there was a platform change deployed yesterday that modified the schema to disallow additional properties.

    I am discussing with the team that own this endpoint whether it is possible to roll back at least until we've had some time to release a change that doesn't send these additional properties and for people to adopt it.

  5. bruno-viva commented on Jun 27, 2023

    @bruno-viva

    Hi, I landed here through a Google search, and can confirm I also see this error on our end with:

    "public" is not a permitted key

    I am using the REST API with PATCH. The request data is in a json format, and in the top level there is this attribute:

    "public": "true",

    This has been working for a while, and it started failing at the 26th around 15h UTC. Thanks for looking into this @williammartin !

  6. added
    priority-1Affects a large population and inhibits work
    and removed on Jun 27, 2023
  7. williammartin commented on Jun 27, 2023

    @williammartin
    Member

    @Petesta @alex-petrov-vt @bruno-kakele

    A deployment has just gone out which should revert this breaking change. Can you please confirm on your end?

    ➜  cli git:(trunk) ✗ EDITOR=nvim ~/workspace/cli/bin/gh gist edit https://gist.github.com/williammartin/c7970e50dcd30139d6b7434714ee79a5
    ➜  cli git:(trunk) ✗ echo $?
    0
  8. alex-petrov-vt commented on Jun 27, 2023

    @alex-petrov-vt
    Contributor

    @williammartin Yep, looks like that fixed it on my end. Thank you!

  9. williammartin commented on Jun 27, 2023

    @williammartin
    Member

    I've tentatively opened #7635 to allow the API team to move forward more safely with this change at some point in the future if they want.

    In the mean time I'll keep this open until tomorrow in case anyone else wants to share, and if I don't hear anything then I will close it.

    Thank you all for your contribution to this issue. Although it's not ideal for your CLI experience to be broken, your involvement in the community helped us catch this breaking change and get it fixed relatively quickly. 🙏

  10. williammartin commented on Jun 29, 2023

    @williammartin
    Member

    As I haven't heard back from anyone, closing this is as resolved.

  11. Petesta commented on Apr 21, 2024

    @Petesta
    Author

    @williammartin There’s been a lot going on and thank you for resolving this.

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 workingplatformProblems with the GitHub platform rather than the CLI clientpriority-1Affects a large population and inhibits work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions