thinkingmachines / linksight-2018

LinkSight is a web app for applying the Philippine Standard Geographic Code to messy and misspelled barangay, municipality, city, and province names.
https://linksight.thinkingmachin.es
GNU General Public License v3.0
11 stars 1 forks source link

List expected error messages #338

Closed ghost closed 5 years ago

ljvmiranda921 commented 5 years ago

Possible error messages for API client + LinkSight integ (note that I'm referring to this set of HTTP status codes):

I'll be posting some code snippets, here's how you can set it up locally

import os
from dotenv import load_dotenv
import linksight

load_dotenv()
API_TOKEN = os.getenv('API_TOKEN')

400: Unrecognized column name/s: {}

Useful for catching wrong/misspelled column names. How to reproduce (using LinkSight client):

ls = linksight.Client(API_TOKEN)
with open('/path/to/dataset.csv') as fp:
    ds = ls.create_dataset(fp)

match = ds.match(source_prov_col='Provence') # Should be province

Related Sentry Issue

415: Unsupported media type. Please use a CSV/TXT/XLSX file.

Useful for catching unsupported types. From the server side, the file is still processed and only fails when match is called. My suggestion is to catch this right away before they even interact with the /match endpoint

ls = linksight.Client(API_TOKEN)
with open('/path/to/dataset.pdf') as fp: # not a CSV file (here it's a PDF file, why not)
    ds = ls.create_dataset(fp)

match = ds.match(source_prov_col='Province')
ljvmiranda921 commented 5 years ago

For now these are the major error messages that we should have server-side.