Skip to content

AttributeError: 'NoneType' object has no attribute 'keys' #1258

@allmightyspiff

Description

@allmightyspiff

From call-api I sometimes get this error.

$ slcli -vvv  call-api SoftLayer_Location_Datacenter getHardwareRouters --id=1854895
Calling: SoftLayer_Location_Datacenter::getHardwareRouters(id=1854895, mask='', filter='{}', args=(), limit=None, offset=None))
Starting new HTTPS connection (1): api.softlayer.com:443
https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Location_Datacenter/1854895/getHardwareRouters.json HTTP/1.1" 200 5049
Returned Data:
[{'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'bcr01a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'bcr01a.dal13', 'id': 1883692, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': {'id': 1854895, 'longName': 'Dallas 13', 'name': 'dal13', 'statusId': 2, 'hardwareRouters': [None, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'bcr02a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'bcr02a.dal13', 'id': 1411193, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'fcr01a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'fcr01a.dal13', 'id': 1076163, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None,'topLevelLocation': None}, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'fcr02a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'fcr02a.dal13', 'id': 1415017, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}]}}, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'bcr02a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'bcr02a.dal13', 'id': 1411193, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': {'id': 1854895, 'longName': 'Dallas 13', 'name': 'dal13', 'statusId': 2, 'hardwareRouters': [{'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'bcr01a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'bcr01a.dal13', 'id': 1883692, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}, None, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'fcr01a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'fcr01a.dal13', 'id': 1076163, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'fcr02a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'fcr02a.dal13', 'id': 1415017, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}]}}, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'fcr01a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'fcr01a.dal13', 'id': 1076163, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': {'id': 1854895, 'longName': 'Dallas 13', 'name': 'dal13', 'statusId': 2, 'hardwareRouters': [{'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'bcr01a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'bcr01a.dal13', 'id': 1883692, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'bcr02a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'bcr02a.dal13', 'id': 1411193, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}, None, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'fcr02a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'fcr02a.dal13', 'id': 1415017, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}]}}, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'fcr02a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'fcr02a.dal13', 'id': 1415017, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': {'id': 1854895, 'longName': 'Dallas 13', 'name': 'dal13', 'statusId': 2, 'hardwareRouters': [{'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'bcr01a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'bcr01a.dal13', 'id': 1883692, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com','fullyQualifiedDomainName': 'bcr02a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'bcr02a.dal13', 'id': 1411193, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}, {'accountId': 1, 'bareMetalInstanceFlag': 0, 'domain': 'softlayer.com', 'fullyQualifiedDomainName': 'fcr01a.dal13.softlayer.com', 'hardwareStatusId': 5, 'hostname': 'fcr01a.dal13', 'id': 1076163, 'notes': '', 'provisionDate': None, 'serviceProviderId': 1, 'serviceProviderResourceId': None, 'topLevelLocation': None}, None]}}]
An unexpected error has occured:
Traceback (most recent call last):
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\core.py", line 207, in main
    cli.main(**kwargs)
  File "c:\users\allmi\source\py37\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\allmi\source\py37\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\allmi\source\py37\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\allmi\source\py37\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\allmi\source\py37\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\users\allmi\source\py37\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\call_api.py", line 166, in cli
    env.fout(formatting.iter_to_table(result))
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\formatting.py", line 393, in iter_to_table
    return _format_list(value)
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\formatting.py", line 420, in _format_list
    return _format_list_objects(result)
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\formatting.py", line 441, in _format_list_objects
    value = iter_to_table(item.get(key))
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\formatting.py", line 395, in iter_to_table
    return _format_dict(value)
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\formatting.py", line 407, in _format_dict
    value = iter_to_table(value)
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\formatting.py", line 393, in iter_to_table
    return _format_list(value)
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\formatting.py", line 420, in _format_list
    return _format_list_objects(result)
  File "c:\users\allmi\source\py37\lib\site-packages\SoftLayer\CLI\formatting.py", line 433, in _format_list_objects
    all_keys = all_keys.union(item.keys())
AttributeError: 'NoneType' object has no attribute 'keys'

Feel free to report this error as it is likely a bug:
    https://github.com/softlayer/softlayer-python/issues
The following snippet should be able to reproduce the error


formatting.py should likely handle this better.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions