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.

AttributeError: 'dict' object has no attribute 'json' on

See original GitHub issue

Hello everyone,

I’m trying this library, and I have to admit that I’m pretty new to it, so maybe I’m doing something wrong.

I want to authenticate to a Vault server using Userpass method.

I created a client without problems, the vault is already unsealed, but I get an error like this:

>>> client = hvac.Client(url='MY_SERVER')
>>> client.sys.is_sealed()                                                                                                                                                                                
>>> login_response = client.auth.userpass.login( 
   ...      username="MY_USERNAME", 
   ...      password="MY_PASSWORD"
   ...     ) 
AttributeError                            Traceback (most recent call last)
<ipython-input-19-186fe49f4016> in <module>
----> 1 client.auth.userpass.login(username=username, password=password)

~/.virtualenvs/vualt/lib/python3.6/site-packages/hvac/api/auth_methods/ in login(self, username, password, mount_point)
    138             json=params,
    139         )
--> 140         return response.json()

AttributeError: 'dict' object has no attribute 'json'

Inspecting the file, I found that some methods are returned like response.json(), and others returned like ... ). I checked other files and most of the returns are like the second one.

Deleting the .json() seems to work.

Is a problem in the library or from by side?


Issue Analytics

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

github_iconTop GitHub Comments

jeffwecancommented, May 4, 2020

Howdy @checor! This looks like a bug introduced in the v0.10.1. I’ll try to get a fix merged in and released over the next few days.

In the meantime, I believe downgrading to v0.10.0 should allow you to work around the issue for now.

jeffwecancommented, Jul 16, 2020

Ah yeah that makes sense and I had neglected considering having to support both variations. In general, the adapter attribute is not intended to for use by callers external to the module (this is obviously somewhat implicit unfortunately as the attribute is not marked as “private” here). Migrating to the more high-level client.write() method should allow you to avoid that sort of logic I believe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'dict' object has no attribute 'read' - Stack Overflow
Since you want to convert it into json format, you should use json.dumps() instead of json.load() . This would work: >>> import json...
Read more >
AttributeError: 'dict' object has no attribute 'read' | bobbyhadz
The "AttributeError: 'dict' object has no attribute 'read'" occurs when we try to access the read attribute on a dictionary, e.g. by passing...
Read more >
'dict' object has no attribute 'write' : r/learnpython - Reddit
Using this code i got this error: 'dict' object has no attribute 'write' Code: users = {} data = [json.dumps(users)] data.append({nickname: ...
Read more >
Python3: AttributeError: 'dict' object has no attribute 'itervalues'
Plugin fails in Python3: Traceback (most recent call last): File "trac\web\", line 617, in dispatch_request dispatcher.dispatch(req) File ...
Read more >
Ansible dict object has no attribute stdout (or) stderr
Generally, we display the stdout (or) stderr of the task at runtime by calling the corresponding task's register within the debug module and ......
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 Post

No results found

github_iconTop Related Hashnode Post

No results found