balanced / balanced-api

Balanced API specification.
221 stars 72 forks source link

'no member defaultdict' being exposed #479

Open steveklabnik opened 10 years ago

steveklabnik commented 10 years ago

Trying to run this scenario:

  Scenario: Add a card to a customer                                                                                                                               
    Given I have created a customer                                                                                                                                
    When I make a PATCH request to the href "href" with the body:                                                                                                  
      """                                                                                                                                                          
        [{                                                                                                                                                         
          "op": "replace",                                                                                                                                         
          "path": "/cards/0/links/customer",                                                                                                                       
          "value": "<%= @customer_id %>"                                                                                                                              
        }]                                                                                                                                                         
      """                                                                                                                                                          
    Then I should get a 200 OK status code                                                                                                                         
    And the response is valid according to the "cards" schema                                                                                                      
    And the fields on this card match:                                                                                                                             
      """                                                                                                                                                          
        {                                                                                                                                                          
          "links": { "customer": "<%= @customer_id %>" }                                                                                                          
        }                                                                                                                                                          
      """                                                              

I get this error, with an HTTP 409

member 'cards' not found in defaultdict(None, {u'customers': [{'name': u'Henry Ford', u'links': {'source': u'CC6MbTsE8nC4Jo7OT334C6ME', 'destination': None}, 'crea
ted_at': datetime.datetime(2014, 1, 14, 19, 34, 21, 666473), 'dob_month': 7, 'merchant_status': u'underwritten', 'updated_at': datetime.datetime(2014, 1, 14, 19, 3
4, 24, 210404), 'phone': None, u'href': '/customers/CU6KV0CM2YQ5E3LdZvLi2XhI', 'meta': {}, 'dob_year': 1863, 'email': None, 'address': {'city': None, 'line2': None
, 'line1': None, 'state': None, 'postal_code': u'48120', 'country_code': None}, 'business_name': None, 'ssn_last4': None, 'id': u'CU6KV0CM2YQ5E3LdZvLi2XhI', 'ein':
 None}], u'links': {u'customers.source': '/resources/{customers.source}', u'customers.card_holds': '/customers/{customers.id}/card_holds', u'customers.cards': '/cu
stomers/{customers.id}/cards', u'customers.debits': '/customers/{customers.id}/debits', u'customers.destination': '/resources/{customers.destination}', u'customers
.bank_accounts': '/customers/{customers.id}/bank_accounts', u'customers.transactions': '/customers/{customers.id}/transactions', u'customers.refunds': '/customers/
{customers.id}/refunds', u'customers.reversals': '/customers/{customers.id}/reversals', u'customers.orders': '/customers/{customers.id}/orders', u'customers.credit
s': '/customers/{customers.id}/credits'}}). Your request id is OHMdfd35dc67d5211e3b6a9026ba7cd33d0..  

Exposing that python stuff seems bad....

matthewfl commented 10 years ago

Just clarifying that the issue here is that the patch request is malformed as there is no cards object on the the dict, which results in defaultdict being exposed.

steveklabnik commented 10 years ago

Yup, makes sense. I still think this is a bad error message.

mjallday commented 10 years ago

Code for this is https://github.com/PoundPay/balanced/blob/master/balanced_service/resources/__init__.py#L113