Cannot create a record


Great project here! Thanks for making it open source!

I’m trying to create a record from react and… I’m getting a very weird error:

Uncaught (in promise) Error: IHP.NameSupport: ParseErrorBundle {bundleErrors = TrivialError 4 (Just (Tokens ('_' :| ""))) (fromList [Label ('d' :| "igit"),Label ('l' :| "owercase letter"),Label ('u' :| "ppercase letter"),EndOfInput]) :| [], bundlePosState = PosState {pstateInput = "user_id", pstateOffset = 0, pstateSourcePos = SourcePos {sourceName = "", sourceLine = Pos 1, sourceColumn = Pos 1}, pstateTabWidth = Pos 8, pstateLinePrefix = ""}} (value to be transformed: "user_id")
CallStack (from HasCallStack):
  error, called at ./IHP/NameSupport.hs:122:35 in ihp-0.19.0-2PpNJYQzcPcJ0msRsxaILh:IHP.NameSupport while calling:

createRecord("lists", {
    "name": "List 2",
    "user_id": "c18e99e9-538e-4e90-b61c-fb2ccf9a94eb",
    "id": "8de1d042-4cde-4c97-9fc8-02ae8a93e290",
    "createdAt": "2022-10-26T16:56:14.371Z"

If I create a record from the dashboard, it works like a charm.

The component I use to create the record in the frontend is this:

function NewList() {
    const [listData, setListData] = useState({name: '', user_id: getCurrentUserId()})
    const onChange = (event) => {
        setListData({...listData, name:})
    const sendListData = () => {
        createRecord('lists', listData);

    return <div>
        <input type="text" value={} onChange={onChange} />
        <button onClick={sendListData}>Create list</button>

Seems everything is correct to me, but obviously that’s not the case :grinning:

Anything has any clue about what could be happening here? Thanks in advance for all the help!

Thanks for reporting! The user_id field needs to be named userId in the object passed to createRecord.

The error message is caused because Thin expects the field name user_id to be camel case.