Skip to content

nil fields throw error in backend #92

Description

@dgoldstein1

request:

curl -XPOST \
 "http://localhost:8443/backend/property" \
 -H "content-type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTU5NjQzNDMsInVpZCI6Ijg0MmZiYjczLWUzNzctNDkxNC1iZmM3LWI0NDJhM2VlZjViYSIsInJvbGUiOiJuYXZpZ2F0b3IifQ.TCtKenywqBx6E9CbjzJ6Ot69k30Niy431NLRyHDNxik" \
 -d '{"address":"520 East Main Street","allow_criminal_records":true,"application_fee":5000,"background_screening_company":"Cville Background Screening","bathrooms":1,"bedrooms":2,"bus_line":true,"contact_method":["phone"],"credit_screening_company":"Cville Credit Screening","deposit":500,"elevator":false,"floor":3,"has_basement":true,"housing_type":"apartment","is_available":true,"last_month_rent_required":true,"monthly_rent":1000,"potential_month_available":5,"property_name":"Davids Apartment","school_district":"CHS","shared_bathrooms":0,"unit_apt_no":"9","voucher_type_accepted":[],"voucher_type_not_accepted":[],"wheelchair_accessibility":true,"where_listed":["Zillow"],"year_available":2020,"zip_code":"22902"}'

response:

{
  "code": 500,
  "error": "internal error"
}

error:

housinghub-a… │   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1482, in _handle_dbapi_exception
housinghub-a… │     sqlalchemy_exception, with_traceback=exc_info[2], from_=e
housinghub-a… │   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
housinghub-a… │     raise exception
housinghub-a… │   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
housinghub-a… │     cursor, statement, parameters, context
housinghub-a… │   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
housinghub-a… │     cursor.execute(statement, parameters)
housinghub-a… │   File "/usr/local/lib/python3.6/site-packages/pgdb.py", line 1052, in execute
housinghub-a… │     return self.executemany(operation, [parameters])
housinghub-a… │   File "/usr/local/lib/python3.6/site-packages/pgdb.py", line 1077, in executemany
housinghub-a… │     rows = self._src.execute(sql)
housinghub-a… │ sqlalchemy.exc.IntegrityError: (pg.IntegrityError) ERROR:  null value in column "listing_date" violates not-null constraint
housinghub-a… │ DETAIL:  Failing row contains (88bf2c76-059d-4b15-b54b-3947d3500307, null, null, {}, {}, 520 East Main Street, 22902, 9, Davids Apartment, t, CHS, t, f, 1000, {phone}, t, null, null, 5, 2, 1, 0, t, 5000,
500, t, t, null, {Zillow}, 3, apartment, 2020, Cville Credit Screening, Cville Background Screening, null).
housinghub-a… │
housinghub-a… │ [SQL: INSERT INTO property (id, landlord_id, navigator_id, voucher_type_accepted, voucher_type_not_accepted, address, zip_code, unit_apt_no, property_name, bus_line, school_district,
wheelchair_accessibility, elevator, monthly_rent, contact_method, is_available, date_first_available, last_contact_date, potential_month_available, bedrooms, bathrooms, shared_bathrooms, has_basement, application_fee,
deposit, last_month_rent_required, allow_criminal_records, listing_date, where_listed, floor, housing_type, year_available, credit_screening_company, background_screening_company, last_contacted_by) VALUES (%(id)s,
%(landlord_id)s, %(navigator_id)s, %(voucher_type_accepted)s, %(voucher_type_not_accepted)s, %(address)s, %(zip_code)s, %(unit_apt_no)s, %(property_name)s, %(bus_line)s, %(school_district)s, %(wheelchair_accessibility)s,
%(elevator)s, %(monthly_rent)s, %(contact_method)s, %(is_available)s, %(date_first_available)s, %(last_contact_date)s, %(potential_month_available)s, %(bedrooms)s, %(bathrooms)s, %(shared_bathrooms)s, %(has_basement)s,
%(application_fee)s, %(deposit)s, %(last_month_rent_required)s, %(allow_criminal_records)s, %(listing_date)s, %(where_listed)s, %(floor)s, %(housing_type)s, %(year_available)s, %(credit_screening_company)s,
%(background_screening_company)s, %(last_contacted_by)s)]
housinghub-a… │ [parameters: {'id': UUID('88bf2c76-059d-4b15-b54b-3947d3500307'), 'landlord_id': None, 'navigator_id': None, 'voucher_type_accepted': [], 'voucher_type_not_accepted': [], 'address': '520 East Main Street',
 'zip_code': '22902', 'unit_apt_no': '9', 'property_name': 'Davids Apartment', 'bus_line': True, 'school_district': 'CHS', 'wheelchair_accessibility': True, 'elevator': False, 'monthly_rent': 1000, 'contact_method':
['phone'], 'is_available': True, 'date_first_available': None, 'last_contact_date': None, 'potential_month_available': 5, 'bedrooms': 2, 'bathrooms': 1, 'shared_bathrooms': 0, 'has_basement': True, 'application_fee':
5000.0, 'deposit': 500.0, 'last_month_rent_required': True, 'allow_criminal_records': True, 'listing_date': None, 'where_listed': ['Zillow'], 'floor': 3, 'housing_type': 'apartment', 'year_available': 2020,
'credit_screening_company': 'Cville Credit Screening', 'background_screening_company': 'Cville Background Screening', 'last_contacted_by': None}]
housinghub-a… │ (Background on this error at: http://sqlalche.me/e/gkpj)
housinghub-a… │
housinghub-a… │ 172.20.0.3 - - [28/Jul/2020 16:36:36] "POST /property HTTP/1.1" 500 -

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions