Error when combining `cml pr` and `cml send-comment --pr`
See original GitHub issueI’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:
- Created 2 years ago
- Reactions:2
- Comments:13 (13 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes we use the GH API (rather than Git directly) for
send-comment --pr
so magic likeHEAD
won’t work. We should doAlso minor note, we maybe want to add aliases
--commit-ref, --head-ref
to the existing--commit-sha, --head-sha
.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–knowngit 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 theGITHUB_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 platformcml
is running on.