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

TypeError: execv() argument 1 must be encoded string without NULL bytes, not str #1

Closed
n8felton opened this issue Apr 17, 2014 · 5 comments

Comments

@n8felton
Copy link

I'm not sure if anyone is still watching this, but I've run into an issue and I'm still not very good with Python.

python /opt/hookhandler/gitlab-webhook.py --port 8000 git@<removed> /media/gitrepo/
April 16 21:28:29 INFO Starting HTTP Server at 0.0.0.0:8000.
April 16 21:28:48 INFO Received POST request.
<removed> - - [16/Apr/2014 21:28:48] "POST / HTTP/1.1" 200 -
April 16 21:28:48 DEBUG Running command: git clone --depth 1 -o origin -b master git@<removed>/test.git master
----------------------------------------
Exception happened during processing of request from ('<removed>', 58697)
Traceback (most recent call last):
  File "/usr/lib64/python2.6/SocketServer.py", line 293, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib64/python2.6/SocketServer.py", line 319, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib64/python2.6/SocketServer.py", line 332, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python2.6/SocketServer.py", line 627, in __init__
    self.handle()
  File "/usr/lib64/python2.6/BaseHTTPServer.py", line 329, in handle
    self.handle_one_request()
  File "/usr/lib64/python2.6/BaseHTTPServer.py", line 323, in handle_one_request
    method()
  File "/opt/hookhandler/gitlab-webhook.py", line 62, in do_POST
    self.update_branch(branch_to_update)
  File "/opt/hookhandler/gitlab-webhook.py", line 84, in update_branch
    return self.add_branch(branch)
  File "/opt/hookhandler/gitlab-webhook.py", line 77, in add_branch
    (branch, repository, branch))
  File "/opt/hookhandler/gitlab-webhook.py", line 118, in run_command
    stderr=subprocess.STDOUT)
  File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child
    raise child_exception
TypeError: execv() argument 1 must be encoded string without NULL bytes, not str
----------------------------------------

Any help you might be able to provide would be great.

@n8felton
Copy link
Author

I should note this is on a RHEL 6.5 Server box while trying to receive a webhook from GitLab 6.5.1 (2ffa03a)

@vinodc
Copy link
Owner

vinodc commented Apr 17, 2014

@n8felton I've only tested this on python2.7. It looks like the clone is failing for some reason. Is the git repository an ascii string? If it isn't, it could convert the entire command to be a unicode string. Could you modify the python code to also log what shlex.split(command) is after line 116?

@n8felton
Copy link
Author

Looks like a Python 2.6.6 issue. I complied and ran with Python 2.7.6 and it worked just fine. Thanks for the quick reply though!

@romracer
Copy link

This looks like a bug with shlex in older versions of Python. I was able to solve it by changing line 128-129 (at least in the current master version) to the following (change is to the shlex portion):

    process = subprocess.Popen(shlex.split(command.encode('ascii')), stdout=subprocess.PIPE,
                               stderr=subprocess.STDOUT)

I'm successfully using this on RHEL 6.5 with stock Python 2.6. I did have to install argparse, but this can be done with "yum install python-setuptools ; easy_install pip ; pip install argparse" or you can download the tarball and "python setup.py install" it.

@vinodc
Copy link
Owner

vinodc commented Aug 28, 2014

Thanks @romracer. I've made the fix to the master branch.

ChristianBeer added a commit to BOINC/boinc that referenced this issue Nov 16, 2015
An issue with unicode strings in python 2.4 and 2.6 (and possibly 2.5) prevents shlex to split the command which leads to the daemon or task not starting. The unicode issue seems to be fixed in python 2.7. The exact error message is: "TypeError: execv() argument 1 must be (encoded string without NULL bytes), not str".

See: vinodc/gitlab-webhook-branch-deployer#1
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

3 participants