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

pr + comment create Error: PR for commit sha not found #1418

Open
BradyJ27 opened this issue Aug 24, 2023 · 14 comments
Open

pr + comment create Error: PR for commit sha not found #1418

BradyJ27 opened this issue Aug 24, 2023 · 14 comments

Comments

@BradyJ27
Copy link
Contributor

I have a basic GitLab CI pipeline that looks like:
Related to https://discord.com/channels/485586884165107732/728693131557732403/1144379101176660029

cml pr .
echo README.md >> report.md
cml comment create --target=pr report.md

I am getting an error:

{"level":"error","message":"PR for commit sha \"4d2069245c68a65774a4a0d64a1efb3611a93b55\" not found","stack":"Error: PR for commit sha \"4d2069245c68a65774a4a0d64a1efb3611a93b55\" not found\n    at parseCommentTarget (/usr/lib/node_modules/@dvcorg/cml/src/commenttarget.js:54:13)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async CML.commentCreate (/usr/lib/node_modules/@dvcorg/cml/src/cml.js:308:20)\n    at async Object.exports.handler (/usr/lib/node_modules/@dvcorg/cml/bin/cml/comment/create.js:11:15)"}

I've set up an example repo with the run results here: https://gitlab.com/bjohnson210/cml-pr-bug/-/jobs/4945761331 to reproduce this issue.

@dacbd
Copy link
Contributor

dacbd commented Aug 24, 2023

In your example, it looks like a PR was never created, so it couldn't find PR with that commit in it.

In your original discord message maybe there was a bit of a race condition in gitlab hadn't yet created the PR when cml comment create attempted to send the API request to gitlab.

@BradyJ27
Copy link
Contributor Author

BradyJ27 commented Aug 25, 2023

In your example, it looks like a PR was never created, so it couldn't find PR with that commit in it.

In your original discord message maybe there was a bit of a race condition in gitlab hadn't yet created the PR when cml comment create attempted to send the API request to gitlab.

Oops, the Public GitLab runners are on 16.x which causes some issue which was fixed in #1404 , but that hasn't been part of a release yet. I don't know if GitLab has any runners on older versions where I can reproduce. I will test to make sure it's not a race condition

@dacbd
Copy link
Contributor

dacbd commented Aug 25, 2023 via email

@BradyJ27
Copy link
Contributor Author

After adding a sleep 30 (in my private repo) I am still getting the same error. I am using cml pr . instead of cml pr create ., not sure if that makes a difference.

@dacbd
Copy link
Contributor

dacbd commented Aug 25, 2023

@BradyJ27 I've completed a new release. Can you check and see if this solved the problem?

@BradyJ27
Copy link
Contributor Author

@dacbd It looks like GitLab CI isn't able to pull the newest version of the docker image, it is still running on CML v0.19.1. It may take some time for it to update, so I can try again in a little bit. Let me know if you see anything wrong with the setup below

Here is my .gitlab-ci.yml:

train-and-report:
  image: iterativeai/cml:latest
  script:
    - cml --version
    - cml ci
    - echo "Add new file" >> file.txt
    - cml pr .
    - cat README.md >> report.md
    - sleep 30
    - cml comment create --target=pr report.md

and here is the output of the job:

image

@dacbd
Copy link
Contributor

dacbd commented Aug 25, 2023

@BradyJ27 sorry, I was able to rebuild the images, give it another try for me

@BradyJ27
Copy link
Contributor Author

BradyJ27 commented Aug 25, 2023

@dacbd Yep, I was able to reproduce now with updated image. https://gitlab.com/bjohnson210/cml-pr-bug/-/jobs/4956922294

cml pr . outputs https://gitlab.com/bjohnson210/cml-pr-bug/-/merge_requests/1
then cml comment create --target=pr outputs:

{"level":"error","message":"PR for commit sha \"78350418cc66e1d6e931fcf3d1eea99190ad01d7\" not found","stack":"Error: PR for commit sha \"78350418cc66e1d6e931fcf3d1eea99190ad01d7\" not found\n    at parseCommentTarget (/usr/lib/node_modules/@dvcorg/cml/src/commenttarget.js:54:13)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async CML.commentCreate (/usr/lib/node_modules/@dvcorg/cml/src/cml.js:308:20)\n    at async Object.exports.handler (/usr/lib/node_modules/@dvcorg/cml/bin/cml/comment/create.js:11:15)"}

I'm assuming it is not a race condition because there is a 30 second sleep between the two.

@dacbd
Copy link
Contributor

dacbd commented Aug 25, 2023 via email

@BradyJ27
Copy link
Contributor Author

BradyJ27 commented Sep 1, 2023

Hey @dacbd, have you had a chance to look into this at all?

@dacbd
Copy link
Contributor

dacbd commented Sep 5, 2023

@BradyJ27 no sorry I havent been able to get to this, as a work around I would add report.md to you .gitignore and then you can set the body of pr to your report contents like so cml pr --body="$(cat ./report.md)" . you can see here: https://cml.dev/doc/ref/pr#--body

@BradyJ27
Copy link
Contributor Author

BradyJ27 commented Sep 6, 2023

@BradyJ27 no sorry I havent been able to get to this, as a work around I would add report.md to you .gitignore and then you can set the body of pr to your report contents like so cml pr --body="$(cat ./report.md)" . you can see here: https://cml.dev/doc/ref/pr#--body

Sure, this will work, thanks!

@BradyJ27
Copy link
Contributor Author

As info, this issue still persists. If there are any ideas on what needs to change I'd be willing to contribute here.

@dacbd
Copy link
Contributor

dacbd commented Mar 28, 2024

@BradyJ27 sorry, I don't think any of the contributors have the capacity right now to debug and solve this.

You are more than welcome to patch and contribute changes. There are a few places that you will likely need to edit.

  • bin/cml/comment/create.js is the entry point of the cli command
  • src/cml.js is the abstraction layer handling app logic
  • src/drivers/gitlab.js is the gitlab driver responsible for the API calls

I would work backwards from the gitlab driver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants