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

KeyError: 'cidr_prefix_length' when listing IP access control lists #445

Closed
ruipserra opened this issue Aug 30, 2018 · 4 comments · Fixed by #483
Closed

KeyError: 'cidr_prefix_length' when listing IP access control lists #445

ruipserra opened this issue Aug 30, 2018 · 4 comments · Fixed by #483
Labels
code-generation issue deals with generated code difficulty: easy fix is easy in difficulty type: bug bug in the library type: community enhancement feature request not on Twilio's roadmap

Comments

@ruipserra
Copy link

I'm trying to use the REST API to check that certain IP addresses are part of some predefined IP ACLs, and create them if necessary.

I'm getting a KeyError: 'cidr_prefix_length' while trying to list the IP addresses in the IP ACL.

Package Version: 6.16.3
Python Version: Python 2.7.15

Code Snippet

from twilio.rest import Client

account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "my_auth_token"
client = Client(account_sid, auth_token)

ip_access_control_lists = client.sip \
    .ip_access_control_lists \
    .list()

ip_access_control_lists[0] \
    .ip_addresses \
    .list()

Exception/Log

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/.local/share/virtualenvs/venv-nMWwJ5dA/lib/python2.7/site-packages/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py", line 79, in list
    return list(self.stream(limit=limit, page_size=page_size, ))
  File "/root/.local/share/virtualenvs/venv-nMWwJ5dA/lib/python2.7/site-packages/twilio/base/version.py", line 180, in stream
    for record in page:
  File "/root/.local/share/virtualenvs/venv-nMWwJ5dA/lib/python2.7/site-packages/twilio/base/page.py", line 48, in next
    return self.get_instance(next(self._records))
  File "/root/.local/share/virtualenvs/venv-nMWwJ5dA/lib/python2.7/site-packages/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py", line 226, in get_instance
    ip_access_control_list_sid=self._solution['ip_access_control_list_sid'],
  File "/root/.local/share/virtualenvs/venv-nMWwJ5dA/lib/python2.7/site-packages/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py", line 358, in __init__
    'cidr_prefix_length': deserialize.integer(payload['cidr_prefix_length']),
KeyError: 'cidr_prefix_length'    

I tried logging the content of payload (some values removed):

{
  u'date_updated': u'Wed, 29 Aug 2018 20:12:21 +0000', 
  u'friendly_name': u'Mike in the office', 
  u'uri': u'/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SIP/IpAccessControlLists/ALXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IpAddresses/IPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json',
  u'ip_access_control_list_sid': u'ALXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 
  u'account_sid': u'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 
  u'sid': u'IPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 
  u'date_created': u'Wed, 29 Aug 2018 20:12:21 +0000', 
  u'ip_address': u'XXX.XXX.XXX.XXX'
}

Let me know if you need any other information.

Thanks in advance! 🙌

@sbanwart
Copy link

sbanwart commented Nov 6, 2018

I'm getting the same error.

Package Version: 6.19.2
Python Version: 3.7.1

client.api.account.sip.ip_access_control_lists.list()[0].ip_addresses.list()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py", line 79, in list
    return list(self.stream(limit=limit, page_size=page_size, ))
  File "/usr/local/lib/python3.7/site-packages/twilio/base/version.py", line 180, in stream
    for record in page:
  File "/usr/local/lib/python3.7/site-packages/twilio/base/page.py", line 42, in __next__
    return self.next()
  File "/usr/local/lib/python3.7/site-packages/twilio/base/page.py", line 48, in next
    return self.get_instance(next(self._records))
  File "/usr/local/lib/python3.7/site-packages/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py", line 226, in get_instance
    ip_access_control_list_sid=self._solution['ip_access_control_list_sid'],
  File "/usr/local/lib/python3.7/site-packages/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py", line 358, in __init__
    'cidr_prefix_length': deserialize.integer(payload['cidr_prefix_length']),
KeyError: 'cidr_prefix_length'

@PCritchfield
Copy link

👍

@childish-sambino childish-sambino added the type: non-library issue API issue not solvable via the SDK label Sep 17, 2019
@childish-sambino
Copy link
Contributor

This is not a change that can be made in the library. An internal ticket has been filed against the relevant product team.

@childish-sambino
Copy link
Contributor

After speaking with the product team, I believe this occurs when new properties are added but not available to all customers during preview, beta, rollout, etc.

Since the other helper libs do not throw errors when properties are missing, neither should this one.

Adding this to the backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

@childish-sambino childish-sambino added code-generation issue deals with generated code status: help wanted requesting help from the community type: bug bug in the library type: community enhancement feature request not on Twilio's roadmap difficulty: easy fix is easy in difficulty and removed type: non-library issue API issue not solvable via the SDK labels Sep 19, 2019
@childish-sambino childish-sambino removed the status: help wanted requesting help from the community label Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-generation issue deals with generated code difficulty: easy fix is easy in difficulty type: bug bug in the library type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants