Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript: Property 'commits' does not exist on 'payload' #128

Open
3 of 7 tasks
jsjoeio opened this issue Nov 26, 2021 · 10 comments
Open
3 of 7 tasks

TypeScript: Property 'commits' does not exist on 'payload' #128

jsjoeio opened this issue Nov 26, 2021 · 10 comments
Labels
Status: Blocked Some technical or requirement is blocking the issue Type: Bug Something isn't working as documented

Comments

@jsjoeio
Copy link

jsjoeio commented Nov 26, 2021

Checklist

Environment

Versions

^18.12.

What happened?

It appears that the package doesn't contain all the required fields on payload.

image

Repo: https://github.com/jsjoeio/github-email-extension

Minimal test case to reproduce the problem

Playground Link

What did you expect to happen?

I expected to have the types match actual data.

What the problem might be

Types are missing the correct payload structure for PushEvent

NOTES
Found this issue with my friend @Beraliv

@jsjoeio jsjoeio added the Type: Bug Something isn't working as documented label Nov 26, 2021
@wolfy1339
Copy link
Member

Thanks for this report 👍

There's nothing we can do on our side. The types are auto-generated from GitHub's OpenAPI spec.

Unfortunately, the JS octokit packages don't have an active maintainer anymore, so we cannot update the types for the REST endpoints.

You can check out this discussion for further updates

@jsjoeio
Copy link
Author

jsjoeio commented Nov 26, 2021

Ah bummer! Okay well thank you for the quick update.

@wolfy1339
Copy link
Member

Hi @jsjoeio, Is this still an issue for you with the latest updates that have been made to this project?

@jsjoeio
Copy link
Author

jsjoeio commented Jul 11, 2022

Hi @wolfy1339 - apologies, I don't really have the time these days to check. Here is where I was having issues: https://github.com/jsjoeio/github-email-extension/blob/master/src/content_script.ts#L110

Otherwise, feel to close

@wolfy1339
Copy link
Member

This seems like an issue upstream, the OpenAPI spec isn't complete for this endpoint it seems

@timrogers
Copy link

We'll need an example of a PushEvent with undocumented properties so we can investigate this on the GitHub side - I've requested that here. If anyone can help, that would be amazing.

@wolfy1339
Copy link
Member

It's not that there's undocumented properties on the PushEvent, it's that the property commits isn't defined on the response type of the endpoint

@timrogers
Copy link

I understand that 😊 It'd just be helpful to have an example JSON response that I can share to demonstrate the problem.

@zeevo
Copy link

zeevo commented Dec 28, 2023

Hey everyone 👋 I believe I am also encountering this error.

Sample Code:

import { Endpoints } from "@octokit/types";

const headers = {
  Accept: "application/vnd.github+json",
  Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
  "X-GitHub-Api-Version": "2022-11-28",
};
const events = await fetch(`https://api.github.com/users/${USER}/events`, {
  headers,
});

const eventsBody =
  (await events.json()) as Endpoints["GET /users/{username}/events"]["response"]["data"];

console.log(JSON.stringify(eventsBody[0]));

// TS Error here
console.log(eventsBody[0]?.payload.commits);

Sample JSON from the above response

{
  "id": "34372140454",
  "type": "PushEvent",
  "actor": {
    "id": 8338013,
    "login": "zeevo",
    "display_login": "zeevo",
    "gravatar_id": "",
    "url": "https://api.github.com/users/zeevo",
    "avatar_url": "https://avatars.githubusercontent.com/u/8338013?"
  },
  "repo": {
    "id": 491694170,
    "name": "zeevo/t3-shadcn-ui",
    "url": "https://api.github.com/repos/zeevo/t3-shadcn-ui"
  },
  "payload": {
    "repository_id": 491694170,
    "push_id": 16384823630,
    "size": 1,
    "distinct_size": 1,
    "ref": "refs/heads/main",
    "head": "134abf5f3317c211a910774108b4ab663f7bed10",
    "before": "35fa50377a011b15125d819a1f3910368f27675d",
    "commits": [
      {
        "sha": "134abf5f3317c211a910774108b4ab663f7bed10",
        "author": {
          "email": "[email protected]",
          "name": "zeevo"
        },
        "message": "upgrade to [email protected]",
        "distinct": true,
        "url": "https://api.github.com/repos/zeevo/t3-shadcn-ui/commits/134abf5f3317c211a910774108b4ab663f7bed10"
      }
    ]
  },
  "public": true,
  "created_at": "2023-12-22T20:55:32Z"
}

Hope this helps and thanks for the types! 👍

@wolfy1339
Copy link
Member

Unfortunately this issue is in GitHub's court. It doesn't seem to be a high priority for them since it's been open for over a year.

We'd need to collect more information in order to create some overrides to add in the missing types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Blocked Some technical or requirement is blocking the issue Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

4 participants