← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 2066115] [NEW] Prevent KeyError getting value of optional data

 

Public bug reported:

Problem: Some of optional data is retrieved in this way:
        backup_name = data['backup_name'] or None
        volume_id = data['volume_id'] or None

etc...

When the key does not exist, KeyError will be raised.
Moreover, or None here is meaningless.

Solution:
Change to         
        backup_name = data.get('backup_name')
        volume_id = data.get('volume_id')

** Affects: horizon
     Importance: Undecided
     Assignee: Nguyen Luu Hoang Minh (minhnlh2)
         Status: New

** Changed in: horizon
     Assignee: (unassigned) => Nguyen Luu Hoang Minh (minhnlh2)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/2066115

Title:
  Prevent KeyError getting value of optional data

Status in OpenStack Dashboard (Horizon):
  New

Bug description:
  Problem: Some of optional data is retrieved in this way:
          backup_name = data['backup_name'] or None
          volume_id = data['volume_id'] or None

  etc...

  When the key does not exist, KeyError will be raised.
  Moreover, or None here is meaningless.

  Solution:
  Change to         
          backup_name = data.get('backup_name')
          volume_id = data.get('volume_id')

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/2066115/+subscriptions