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

cml comment create error on GitLab #1328

Open
l-kuo opened this issue Jan 30, 2023 · 18 comments
Open

cml comment create error on GitLab #1328

l-kuo opened this issue Jan 30, 2023 · 18 comments
Assignees
Labels
awaiting-response Waiting for user feedback ci-gitlab cml-comment Subcommand external-request You asked, we did p0-critical Max priority (ASAP) question User requesting support

Comments

@l-kuo
Copy link

l-kuo commented Jan 30, 2023

Please see the error logs below.

> $ cat reports/metrics.json >> report.md
> $ echo '![](reports/confusion_testing.png "Confusion Matrix")' >> report.md
> $ cml comment create report.md
> {"level":"error","message":"Not Found","stack":"Error: Not Found\n    at Gitlab.request (/usr/lib/node_modules/@dvcorg/cml/src/drivers/gitlab.js:553:13)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async Gitlab.commitPrs (/usr/lib/node_modules/@dvcorg/cml/src/drivers/gitlab.js:105:17)\n    at async parseCommentTarget (/usr/lib/node_modules/@dvcorg/cml/src/commenttarget.js:39:25)\n    at async CML.commentCreate (/usr/lib/node_modules/@dvcorg/cml/src/cml.js:283:20)\n    at async Object.exports.handler (/usr/lib/node_modules/@dvcorg/cml/bin/cml/comment/create.js:11:15)"}
> Cleaning up file based variables
> 00:01
> ERROR: Job failed: exit code 1
> 


> $ cat reports/metrics.json >> report.md
> $ echo '![](reports/confusion_testing.png "Confusion Matrix")' >> report.md
> $ cml comment create --log=debug report.md
> {"level":"debug","message":"Gitlab API request, method: GET, url: \"https://gitlab-xxx.com/api/v4/version\""}
> {"level":"debug","message":"Gitlab API request, method: GET, url: \"https://gitlab-xxx.com/project/api/v4/version\""}
> {"level":"debug","message":"Response status is 404"}
> {"level":"debug","message":"Gitlab API request, method: GET, url: \"https://gitlab-xxx.com/api/v4/projects/project_repo/repository/commits/commit_num/merge_requests\""}
> {"level":"debug","message":"Response status is 404"}
> {"level":"debug","message":"Send analytics failed: Cannot read properties of undefined (reading 'startsWith')"}
> {"level":"error","message":"Not Found","stack":"Error: Not Found\n    at Gitlab.request (/usr/lib/node_modules/@dvcorg/cml/src/drivers/gitlab.js:553:13)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async Gitlab.commitPrs (/usr/lib/node_modules/@dvcorg/cml/src/drivers/gitlab.js:105:17)\n    at async parseCommentTarget (/usr/lib/node_modules/@dvcorg/cml/src/commenttarget.js:39:25)\n    at async CML.commentCreate (/usr/lib/node_modules/@dvcorg/cml/src/cml.js:283:20)\n    at async Object.exports.handler (/usr/lib/node_modules/@dvcorg/cml/bin/cml/comment/create.js:11:15)"}
> Cleaning up file based variables
> 00:01
> ERROR: Job failed: exit code 1

The above is my debug log.
Anyway, all the cml command are resulting in the same error. FYI, I am using custom built image with installed dvc and cml package. DVC is working fine but not cml part.

@DavidGOrtega
Copy link
Contributor

👋 were you able to try as suggested in discord the api endpoint to see if it works?

curl -v -H "Authorization: Bearer $REPO_TOKEN" https://gitlab-aic.dynu.com/api/v4/version

As I stated the problem is the access to your self hosted gitlab instance

@DavidGOrtega DavidGOrtega added the awaiting-response Waiting for user feedback label Jan 30, 2023
@l-kuo
Copy link
Author

l-kuo commented Jan 30, 2023

Yes, I tried according to suggestion and the API endpoint is working well.

@l-kuo l-kuo closed this as completed Jan 30, 2023
@l-kuo l-kuo reopened this Jan 30, 2023
@DavidGOrtega
Copy link
Contributor

DavidGOrtega commented Jan 30, 2023

can you please paste the response 🙏 ?

@0x2b3bfa0 passed to me @l-kuo

@DavidGOrtega DavidGOrtega added awaiting-response Waiting for user feedback and removed awaiting-response Waiting for user feedback labels Jan 30, 2023
@casperdcl casperdcl added cml-comment Subcommand external-request You asked, we did p0-critical Max priority (ASAP) labels Feb 1, 2023
@0x2b3bfa0
Copy link
Member

Context: as per discord#cml/1069545494277279845, the API endpoint is working correctly.

$ curl -v -H "Authorization: Bearer [MASKED]" https://gitlab-aic.dynu.com/api/v4/version
{"version":"...","revision":"...", ..., "enterprise":true}

@tasdomas
Copy link
Contributor

tasdomas commented Feb 1, 2023

Is the commit_num entry in the request (from the debug log) corresponding to the head commit of the PR?

> {"level":"debug","message":"Gitlab API request, method: GET, url: \"https://gitlab-xxx.com/api/v4/projects/project_repo/repository/commits/commit_num/merge_requests\""}

@0x2b3bfa0

This comment was marked as outdated.

@0x2b3bfa0
Copy link
Member

Can you please run this and send us the output?

curl -v -H "Authorization: Bearer $REPO_TOKEN" https://$HOST/api/v4/projects/$PROJECT/repository/commits/$COMMIT_HASH/merge_requests/

@l-kuo
Copy link
Author

l-kuo commented Feb 2, 2023

Can you please run this and send us the output?

curl -v -H "Authorization: Bearer $REPO_TOKEN" https://$HOST/api/v4/projects/$PROJECT/repository/commits/$COMMIT_HASH/merge_requests/

I sent it via discord message sir, thanks.

@tasdomas
Copy link
Contributor

tasdomas commented Feb 7, 2023

@0x2b3bfa0 - could you add the sanitized report to the issue?

@0x2b3bfa0
Copy link
Member

0x2b3bfa0 commented Feb 8, 2023

@l-kuo, do you also get a 404 error when navigating to https://host/api/v4/projects/group%252Fproject1 on your browser?

Footnotes

  1. Redacted with placeholders, sent the full URL on a Discord direct message.

@0x2b3bfa0
Copy link
Member

0x2b3bfa0 commented Feb 8, 2023

@l-kuo is using GitLab Enterprise Edition 15.6.1 fe39c71ac74 and has provided the result for the following queries:

Using the project's percent-encoded normalized slug 🚫

https://host/api/v4/projects/group%2Fproject

{"error":"404 Not Found"}

Using the project's numeric identifier ✅

https://host/api/v4/projects/identifier

{...}

@0x2b3bfa0
Copy link
Member

0x2b3bfa0 commented Feb 8, 2023

The actual project and group names don't seem to have nothing to do with this issue, but the following API responses I got from local testing might shed some light over the issue:

Numeric identifiers

https://host/api/v4/projects/valid-identifier

{...}

https://host/api/v4/projects/invalid-identifier 🚫

{"message":"404 Project Not Found"}

Slugs

https://host/api/v4/projects/valid-group%2Fvalid-project

{...}

https://host/api/v4/projects/invalid-group%2Finvalid-project 🚫

{"message":"404 Project Not Found"}

Malformed (slash not encoded)

https://host/api/v4/projects/valid-group/valid-project 🚫

{"error":"404 Not Found"}

https://host/api/v4/projects/invalid-group/invalid-project 🚫

{"error":"404 Not Found"}

@0x2b3bfa0
Copy link
Member

If some misconfigured proxy is turning url-encoded slashes into literal slashes, the URL suggested in #1328 (comment) should succeed.

@0x2b3bfa0 0x2b3bfa0 added the awaiting-response Waiting for user feedback label Feb 8, 2023
@l-kuo
Copy link
Author

l-kuo commented Feb 11, 2023

@l-kuo, do you also get a 404 error when navigating to https://host/api/v4/projects/group%252Fproject1 on your browser?

Footnotes

  1. Redacted with placeholders, sent the full URL on a Discord direct message. leftwards_arrow_with_hook

Yes, it showed up {"message":"404 Project Not Found"}.

@0x2b3bfa0
Copy link
Member

@l-kuo, can you please confirm that #1328 (comment) is accurate?

  • Request: https://host/api/v4/projects/group%2Fproject
    • Response: {"error":"404 Not Found"}
  • Request: https://host/api/v4/projects/group%252Fproject
    • Response: {"error":"404 Project Not Found"}
  • Request: https://host/api/v4/projects/number
    • Response: project information

Note the difference between Not Found and Project Not Found

@casperdcl casperdcl added the question User requesting support label Feb 14, 2023
@l-kuo
Copy link
Author

l-kuo commented Mar 2, 2023

@l-kuo, can you please confirm that #1328 (comment) is accurate?

  • Request: https://host/api/v4/projects/group%2Fproject

    • Response: {"error":"404 Not Found"}
  • Request: https://host/api/v4/projects/group%252Fproject

    • Response: {"error":"404 Project Not Found"}
  • Request: https://host/api/v4/projects/number

    • Response: project information

Note the difference between Not Found and Project Not Found

Yes, this is absolutely correct response I got.

@0x2b3bfa0
Copy link
Member

0x2b3bfa0 commented Mar 3, 2023

@l-kuo, what output do you get after percent-encoding the whole repository slug?

Example: if the original URL is https://host/api/v4/projects/group%2Fproject, try https://host/api/v4/projects/%67%72%6f%75%70%25%32%46%70%72%6f%6a%65%63%741 instead.

Footnotes

  1. You can use something like printf %s "group%2Fproject"|xxd -p|tr -d \\n|sed s/../%\&/g to convert it.

@l-kuo
Copy link
Author

l-kuo commented Mar 7, 2023

@l-kuo, what output do you get after percent-encoding the whole repository slug?

Example: if the original URL is https://host/api/v4/projects/group%2Fproject, try https://host/api/v4/projects/%67%72%6f%75%70%25%32%46%70%72%6f%6a%65%63%74[1](#user-content-fn-1-0e9c899d1d57e0e154630ea6052c1299) instead.

Footnotes

  1. You can use something like printf %s "group%2Fproject"|xxd -p|tr -d \\n|sed s/../%\&/g to convert it. leftwards_arrow_with_hook

I got this output:

{"message":"404 Project Not Found"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-response Waiting for user feedback ci-gitlab cml-comment Subcommand external-request You asked, we did p0-critical Max priority (ASAP) question User requesting support
Projects
None yet
Development

No branches or pull requests

5 participants