API error when creating a repository in 4.5.1

Yohan Trudel's Avatar

Yohan Trudel

12 Dec, 2016 09:26 PM

Hello Marcin,

Starting since I upgraded to 4.5.1, we started seeing weird error while using the web API.

For example, here's an excerpt of the HTTP exchange between my test machine and the server:

// We are trying to create repository 'Review/ZP-13':
POST /_admin/api HTTP/1.1
Accept: application/json, application/javascript, text/javascript
Content-Length: 243
Content-Type: application/json
Host: 137.237.167.241:8080
Connection: Keep-Alive

{"id":"65c001b3-b9bc-4b10-97b3-adb9a0d2c5a2","auth_token":"xxx","method":"create_repo","args":{"repo_name":"Review/ZP-13","repo_type":"hg","description":"Development Repository for ZP-13","clone_uri":null}}

// And the reply we get from the server:
HTTP/1.1 200 OK
Server: nginx/1.11.4
Date: Mon, 12 Dec 2016 20:19:51 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 196
Connection: keep-alive
Set-Cookie: community-1=002efbae86f7c622130a9bfa6af9ee938e2d1f9bf5d7d35d4d784deda2afb6200f20576c; httponly; Path=/

{
    "error": null,
    "id": "65c001b3-b9bc-4b10-97b3-adb9a0d2c5a2",
    "result": {
        "success": true,
        "msg": "Created new repository `review/zp-13`",
        "task": null
    }
}

At first look, everything seems peachy right? But note the capitalization in the 'msg'. A repository was indeed created, but it was repository 'review/zp-13'. Actually, it was 'Review/zp-13' since the 'Review' folder already existed.

A closer look in the community log file shows the following:

2016-12-12 21:09:55.930 INFO [rhodecode.lib.utils] Logging action:`started_following_repo` on repo:`<RepoTemp('id:95')>` by user:<User('id:2:admin')> ip:127.0.0.1
2016-12-12 21:09:55.945 INFO [rhodecode.lib.utils] Logging action:`user_created_repo` on repo:`review/zp-13` by user:<User('id:2:admin')> ip:127.0.0.1
2016-12-12 21:09:56.004 INFO [rhodecode.model.repo] creating repo zp-13 in /home/ytrudel/repos/Review/zp-13 from url: ``
2016-12-12 21:09:56.023 ERROR [rhodecode.lib.vcs.backends] Perhaps this repository is in db and not in filesystem run rescan repositories with "destroy old data" option from admin panel
Traceback (most recent call last):
  File "/opt/rhodecode/store/q8plg58m9zhhz8jw92xhpk726g1v00jb-python2.7-rhodecode-enterprise-ce-4.5.1/lib/python2.7/site-packages/rhodecode/lib/vcs/backends/__init__.py", line 60, in get_vcs_instance
    raise VCSError("Given path %s is not a directory" % repo_path)
VCSError: Given path /home/ytrudel/repos/review/zp-13 is not a directory
2016-12-12 21:09:56.066 INFO [rhodecode.lib.middleware.request_wrapper] IP: 127.0.0.1 Request to /_admin/api time: 0.202s
2016-12-12 21:09:56.130 INFO [rhodecode.api] Access for IP:127.0.0.1 allowed
2016-12-12 21:09:56.160 INFO [rhodecode.lib.middleware.request_wrapper] IP: 127.0.0.1 Request to /_admin/api time: 0.054s
2016-12-12 21:09:56.215 INFO [rhodecode.api] Access for IP:127.0.0.1 allowed
2016-12-12 21:09:56.243 INFO [rhodecode.lib.middleware.request_wrapper] IP: 127.0.0.1 Request to /_admin/api time: 0.048s

On the file system of the server, I do indeed see a folder with that name:

ytrudel@yohan-ubuntu-001:~/repos/Review$ ll
total 12
drwxr-xr-x 3 ytrudel ytrudel 4096 Dec 12 16:20 ./
drwxrwxr-x 10 ytrudel ytrudel 4096 Dec 12 16:13 ../
drwxr-xr-x 3 ytrudel ytrudel 4096 Dec 12 16:13 zp-13/
ytrudel@yohan-ubuntu-001:~/repos/Review$

I also see that repository on the web interface but if you click on it, you get an error saying 'The repository at review/zp-13 cannot be located.'

Bottomline, it looks to me like something in playing with the capitalization of provided repository names and it's messing up a few things.

Can you shed some light into my theory?

Cheers,
Yohan

  1. Support Staff 1 Posted by Marcin Kuzminsk... on 12 Dec, 2016 10:25 PM

    Marcin Kuzminski's Avatar

    Hi Yohan,

    We added strict validation into the API in 4.5.X release. But in fact the capitalization should be kept. We'll investigate the issue.

  2. 2 Posted by Yohan Trudel on 13 Feb, 2017 04:33 PM

    Yohan Trudel's Avatar

    A long time in coming... but I can confirmed this issue fixed in release 4.6.0.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

23 Nov, 2017 03:02 PM
21 Nov, 2017 06:38 PM
03 Oct, 2017 08:26 PM
03 Oct, 2017 05:48 PM
28 Sep, 2017 05:55 PM