codecov / codecov-browser-extension

A browser extension for Codecov. Works for Chrome and Firefox
Apache License 2.0
37 stars 12 forks source link

Line coverage not shown in specific PR #35

Closed nihaals closed 1 year ago

nihaals commented 1 year ago
githubPR.js:8 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'filter')
    at githubPR.js:8:3425
    at Array.map (<anonymous>)
    at githubPR.js:8:3400
    at githubPR.js:8:3563
    at Generator.next (<anonymous>)
    at i (githubPR.js:8:1197)
g.coverageReport = function(e) {
    let n = e;
    return n = n.filter((e=>e.has_diff)).map((e=>{
        const n = e.lines.filter((e=>e.added)) // `lines.filter` here
            , o = r.default.keyBy(n, (e=>e.number.head));
        return Object.assign(e, {
            lines: o
        })
    }
    )),
    n = r.default.keyBy(n, (e=>e.name.head)),
    n
}(n.files)

Which I assume is: https://github.com/codecov/codecov-browser-extension/blob/c70e406be60a5c2ef0ae81bbee1461fbabda72b7/src/content/github/pr/main.tsx#L144

v0.2.3, both Firefox and Chromium

anukul commented 1 year ago

Can you please share a link to the PR?

nihaals commented 1 year ago

As it's a private repo, can I provide an ID instead?

anukul commented 1 year ago

Not sure if I can use that to debug, but from seeing this error I believe my understanding of the expected API response might be inaccurate (for https://api.codecov.io/api/v2/{service}/{owner_username}/repos/{repo_name}/compare/)

I see the docs mention that response.files[i].lines is a required array of objects, so it's unusual that it's null for a particular PR.

cc @scott-codecov

nihaals commented 1 year ago

Can confirm, one of the files has "lines": null (and none of the other files). I also can't think of anything in particular that's different about this file.

scott-codecov commented 1 year ago

That is indeed unexpected. @nihaals Would you be willing to share the owner username and repo name of the private repo? The repo ID would be fine as well. I'll go investigate what our API is returning. If you'd prefer to not share that publicly you could email me directly at scott@codecov.io

nihaals commented 1 year ago

@scott-codecov I just sent it. If it helps, I can avoid updating the PR for the rest of the day in case that "fixes" the issue.

scott-codecov commented 1 year ago

@nihaals Thanks for the info. I found the issue here - we're truncating some parts of the diff when the number of changed lines exceeds some threshold (as it does in the PR you linked). This was previously used so that UIs could load some of the diff and then incrementally load the rest as needed. I don't think that really applies in the case of the browser extension and since we're already fetching the full diff from GitHub I don't see any reason not to return the whole thing in this case (the response payload may grow in size a bit is all).

Feel free to continue working on your PR. I'll get some changes into our API to resolve this and you can expect the coverage to start showing up once it's deployed sometime in the next couple days. I'll post back here when the change is live.

Thanks for reporting the issue!

scott-codecov commented 1 year ago

@nihaals This should be resolved now. Please try testing again and let me know if you're still experiencing any issues. Thanks!

nihaals commented 1 year ago

It looks like it's fixed now, thanks for the quick fix!