question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when combining `cml pr` and `cml send-comment --pr`

See original GitHub issue

I’m getting the following error:

{
    "level":"error",
    "message":"Cannot destructure property 'url' of 'commitPr' as it is undefined.",
    "stack":"TypeError: Cannot destructure property 'url' of 'commitPr' as it is undefined.\n    at CML.commentCreate (/usr/lib/node_modules/@dvcorg/cml/src/cml.js:126:15)\n    at async Object.exports.handler (/usr/lib/node_modules/@dvcorg/cml/bin/cml/send-comment.js:13:15)"
}

When combining cml pr and cml send-comment --pr in the same workflow.

Here is a minimal example to reproduce:

https://github.com/iterative/test-cml-send-comment-pr

And the failing workflow:

https://github.com/iterative/test-cml-send-comment-pr/runs/4038830121?check_suite_focus=true

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
casperdclcommented, Nov 9, 2021

Yes we use the GH API (rather than Git directly) for send-comment --pr so magic like HEAD won’t work. We should do

commitSha = exec(`git rev-parse -- ${commitSha}`)

Also minor note, we maybe want to add aliases --commit-ref, --head-ref to the existing --commit-sha, --head-sha.

3reactions
0x2b3bfa0commented, Oct 29, 2021

The Real Cause of This Bug ™

By default, the cml send-comment command tries to infer the commit hash instead of asking users for it. While most people would expect this default hash to be the one of the last commit in the current branch, this is not the case.

We’ve adopted a much more exciting approach, parsing the GITHUB_SHA environment variable[^1] and, if it’s unset or empty, resorting to the well–known git rev-parse HEAD command as a fallback.

Despite the popular belief, these two ways of retrieving the last commit hash are not equivalent: the former will not return the last commit in the branch, but rather the commit who triggered the workflow.

Because of this, cml pr will create a new branch, but it won’t affect the value of the GITHUB_SHA environment variable. Hence, cml send-comment will try to find a pull request using the wrong commit hash and fail to do so.

Traceback (most recent call last)

https://github.com/iterative/cml/blob/3037be76affa88c4d382b640215e6b295b22af12/src/cml.js#L125

https://github.com/iterative/cml/blob/3037be76affa88c4d382b640215e6b295b22af12/src/cml.js#L98

https://github.com/iterative/cml/blob/3037be76affa88c4d382b640215e6b295b22af12/src/cml.js#L85-L88

https://github.com/iterative/cml/blob/3037be76affa88c4d382b640215e6b295b22af12/src/drivers/github.js#L502-L507

[^1]: Among others, like CI_COMMIT_SHA for GitLab. It depends on the platform cml is running on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

send-comment PR for commit sha \"HEAD\" not found #880
cml send-comment --update works in a workflow triggered by a PR but cml send-comment --pr ... Error when combining cml pr and cml...
Read more >
Management of Chronic Myeloid Leukemia in Advanced Phase
Management of chronic myeloid leukemia (CML) in advanced phases remains a challenge also in the era of tyrosine kinase inhibitors (TKIs) ...
Read more >
Chronic Myeloid Leukemia (CML)
Amer Zeidan, MBBS at Yale University, is combining TKIs with a drug that targets the PD-1 checkpoint protein on immune system T-cells. Research...
Read more >
FDA approves Novartis Scemblix® (asciminib), with novel ...
Combination Therapy Using Asciminib Plus Imatinib (IMA) in Patients (PTS) with Chronic Myeloid Leukemia (CML): Results from a Phase 1 Study.
Read more >
Continuous Machine Learning. An Introduction to CML ...
This article is for data scientists and engineers looking for a brief guide on understanding Continuous Machine Learning, What it is?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found