question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: 'exceptions.ValueError' object is not callable, when using client.service.create()

See original GitHub issue

Call to client.service.create() fails without understandable error with the following trace:

e = HTTPError(u'500 Server Error: Internal Server Error for url: http+docker://localunixsocket/v1.32/services/create',)

    def create_api_error_from_http_exception(e):
        """
        Create a suitable APIError from requests.exceptions.HTTPError.
        """
        response = e.response
        try:
            explanation = response.json()['message']
        except ValueError:
            explanation = response.content.strip()
        cls = APIError
        if response.status_code == 404:
            if explanation and ('No such image' in str(explanation) or
                                'not found: does not exist or no pull access'
                                in str(explanation) or
                                'repository does not exist' in str(explanation)):
                cls = ImageNotFound
            else:
                cls = NotFound
>       raise cls(e, response=response, explanation=explanation)
E       TypeError: 'exceptions.ValueError' object is not callable

Notes: client object has been created using version=“1.32” but same result with version=‘auto’ or without version

Info:

docker==2.6.1
docker-pycreds==0.2.1
Python 2.7.13
Client:
 Version:      17.09.0-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:40:09 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.09.0-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:45:38 2017
 OS/Arch:      linux/amd64
 Experimental: true

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mbovocommented, Dec 24, 2017

@feliperuhland sorry for the delay, from the python console all is working as expected:

Python 2.7.13 (default, Jul 18 2017, 09:16:53) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> client = docker.from_env()
>>> client.services.create('redis:4.0.1 - alpine', name='redis')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mbovo/fworks/devops/gindrop/venv/lib/python2.7/site-packages/docker/models/services.py", line 177, in create
    service_id = self.client.api.create_service(**create_kwargs)
  File "/Users/mbovo/fworks/devops/gindrop/venv/lib/python2.7/site-packages/docker/utils/decorators.py", line 34, in wrapper
    return f(self, *args, **kwargs)
  File "/Users/mbovo/fworks/devops/gindrop/venv/lib/python2.7/site-packages/docker/api/service.py", line 134, in create_service
    self._post_json(url, data=data, headers=headers), True
  File "/Users/mbovo/fworks/devops/gindrop/venv/lib/python2.7/site-packages/docker/api/client.py", line 228, in _result
    self._raise_for_status(response)
  File "/Users/mbovo/fworks/devops/gindrop/venv/lib/python2.7/site-packages/docker/api/client.py", line 224, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/Users/mbovo/fworks/devops/gindrop/venv/lib/python2.7/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 400 Client Error: Bad Request ("rpc error: code = InvalidArgument desc = ContainerSpec: "redis:4.0.1 - alpine" is not a valid repository/tag")
>>> 

So it seems not a library bug 👍 Using the lib wrapped around Flask is working too. I’m investigating further… the problem is limited to pytest + Flask test_client:

app = Flask(__name__)
appclient = app.test_client()
response = appclient.put('/deploy/deploy_test', content_type='multipart/form-data', data=data)

returns the well known E TypeError: 'exceptions.ValueError' object is not callable

Seems the library docker/errors.py:22 cls = APIError

can’t found the correct APIError class when using pytest + Flask test_client()

Thanks again for your support!

0reactions
feliperuhlandcommented, Jan 3, 2018

@shin- I think we can close this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python TypeError: Object is Not Callable. Why This Error?
The TypeError'str' object is not callable occurs when you access a string by using parentheses. Parentheses are only applicable to callable ...
Read more >
What does "TypeError 'xxx' object is not callable" means?
The action occurs when you attempt to call an object which is not a function, as with () .
Read more >
TypeError: object is not callable in Python | bobbyhadz
The Python "TypeError: object is not callable" occurs when we try to call a not-callable object (e.g. a list or dict) as a...
Read more >
TypeError 'module' object is not callable in Python - STechies
This error statement TypeError: 'module' object is not callable occurs when the user gets confused between Class name and Module name. The issue...
Read more >
What is "typeerror: 'module' object is not callable"
This error statement TypeError: 'module' object is not callable is raised as you are being confused about the Class name and Module name....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found