Cht-conf create-users error: "Wrong type, object is not a place."

Describe the Bug
I’m trying to import some test users into my local development environment by following the steps in the documentation. When I run cht-conf, it reports it created 14 documents, but then shows an error.

How To Reproduce The Issue

  1. Create a CSV file called users.csv put it in csv folder. see below for raw CSV.
  2. Run the cht-conf command: cht csv-to-docs upload-docs create-users --url=
  3. See error: ERROR StatusCodeError: 400 - {"code":400,"error":"Wrong type, object is not a place."}

Expected Behavior
I should see 2 new user in the admin area, two new contacts and two new places. I see none of these. I do see a number of docs in fauxton (14 I’m guessing!)


cht csv-to-docs upload-docs create-users --url=
WARN No project package.json file found at /home/mrjones/Documents/MedicMobile/csv-to-docs/package.json 
WARN Project has no dependency on cht-conf. 
INFO Checking that https://medic:**** is available... 
INFO Processing config in csv-to-docs. 
INFO Actions:
     - csv-to-docs
     - upload-docs
     - create-users 
INFO Starting action: csv-to-docs… 
INFO Processing CSV file: /home/mrjones/Documents/MedicMobile/csv-to-docs/csv/users.csv … 
INFO Users csv has been saved 
INFO csv-to-docs complete. 
INFO Starting action: upload-docs… 
WARN This operation will permanently write 14 docs.  Are you sure you want to continue? 
Are you sure? [y/n]: y
14/14 docs 
INFO Summary: 14 of 14 docs uploaded OK.  Full report written to: upload-docs.1641510399181.log.json 
INFO upload-docs complete. 
INFO Starting action: create-users… 
INFO Creating user alice 
ERROR StatusCodeError: 400 - {"code":400,"error":"Wrong type, object  is not a place."}
    at new StatusCodeError (/usr/lib/node_modules/cht-conf/node_modules/request-promise-core/lib/errors.js:32:15)
    at (/usr/lib/node_modules/cht-conf/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] (/usr/lib/node_modules/cht-conf/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback (/usr/lib/node_modules/cht-conf/node_modules/request/request.js:185:22)
    at Request.emit (events.js:400:28)
    at Request.<anonymous> (/usr/lib/node_modules/cht-conf/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:400:28)
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/cht-conf/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:519:28)
    at IncomingMessage.emit (events.js:412:35)

Input CSV file:

username	password	roles	name	phone	place.c_prop	place.type	place.parent
alice	Secret_1	chw	Alice Example	123456789	Alice	p_val_a	health_center	alice area	
bob	Secret_1	chw	bob Example	123456789	bob	p_val_a	health_center	bob area	

Error JSON file mentioned above:

cat upload-docs.1641510399181.log.json                                                                 
  "ok": [
  "failed": {}


  • Instance: local dev
  • Browser: NA
  • Client platform: Ubuntu 20.04
  • App: cht-conf
  • Version: CHT Docker Helper with CHT 3.13 and cht-conf 3.9.4.

Additional Context
I noticed that pretty much no matter what CSV I use I get this error (like delete the place.type field for example). Also re-running the exact same command it reports “0 of 14 docs created” but then still shows the same error.

Hello @mrjones

I got the same error when I used the csv you provided without editing. The error indicates that the places provided for the users do not exist in your database. You can edit the csv to change the place properties (type, name, and parent) to a place that already exists or you can link to a place created in another csv doc.

Ah - interesting! I want to create new places though which the docs say is allowed. Does that mean I should remove the place.parent column when running the command?

Also I notice there’s two spaces in the error between “object” and “space” which maybe suggests the CHT was going to put something more in there? I could be reading between the lines too much though :wink:

Wrong type, object  is not a place.

I was hoping it would say something more helpful like a column name or row number there!

  • NB - the forum is removing the two spaces when it renders my text via inline code, so using a break out code box which adds extra, incorrect syntax highlighting :man_shrugging:

Testing some more, I’ve distilled the CSV to the bare minimum and still get the error (and real CSV this time, not TSV!):

alice,Secret_1,chw,Alice,health_center,alice area
bob,Secret_1,chw,bob,health_center,bob area

The docs say you only need these 5 columns:

The username, password,, place.type, columns are required to have functional users with new places.

To link to places that are being created in another csv file you will need to have something like place:GET _id OF place WHERE reference_id=COL_VAL on the first line. You can see the documentation for this here.

1 Like

@njuguna - ah - ok - thank you! Looking closely I do see that the docs I originally cited, very much have a place.parent field and placeholder values of disctrict_uuid which I had ignored because I thought i could do it all from one CSV file. I see now that I need to use 3 CSV documents just as you demonstrated.