Fix KeyError when saving repository form

Review Request #6746 — Created Jan. 7, 2015 and submitted

Information

Review Board
master
009bbc7...

Reviewers

A KeyError was raised when certain hosting services (like GitHub) did not contain 'default' as a plan. To fix this, check that 'default' exists in the bug_tracker_forms dictionary before running the remaining validations.

Successfully ran existing scmtools tests. KeyError was no longer raised when a new repository was created.

Description From Last Updated

To reduce the complexity of the code, try: field = self.bug_tracker_forms[bug_tracker_type].get('default') if field: ...

chipx86chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/scmtools/forms.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/scmtools/forms.py
    
    
  2. 
      
brennie
  1. Can you add a bit of info to the summary and description? Just something that mentions not all hosts support default field values.

  2. 
      
david
  1. The code looks OK, but your summary and description need work. The summary should be something like "Fix KeyError when saving repository form", and the description should explain what the bug was and how your change fixes it.

  2. 
      
CR
chipx86
  1. 
      
  2. reviewboard/scmtools/forms.py (Diff revision 1)
     
     
     
    Show all issues

    To reduce the complexity of the code, try:

    field = self.bug_tracker_forms[bug_tracker_type].get('default')
    
    if field:
        ...
    
  3. 
      
CR
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/scmtools/forms.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/scmtools/forms.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
CR
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.0.x (10be24f)
CR
  1. Ship It!
  2.