Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return better error message when email is not specified #930

Open
matthew-white opened this issue Jul 17, 2023 · 0 comments · May be fixed by #1066
Open

Return better error message when email is not specified #930

matthew-white opened this issue Jul 17, 2023 · 0 comments · May be fixed by #1066

Comments

@matthew-white
Copy link
Member

It looks like /v1/users/reset/initiate will return a 500 error if the request body does not have an email property. It'd be better if Central returned a 400 error with a more informative message.

We saw such a request in a deployment of Central v2023.3.1. As to why the request body didn't have an email property, it looks like the Content-Type header of the request was multipart/form-data, not application/json. The following error was thrown:

InvalidInputError: SQL tag cannot be bound an undefined value.
  File "/usr/odk/node_modules/slonik/dist/src/factories/createSqlTag.js", line 27, col 19, in sql
    throw new errors_1.InvalidInputError('SQL tag cannot be bound an undefined value.');
  File "/usr/odk/lib/util/db.js", line 218, col 12, in equals
    : sql`${sql.identifier(k.split('.'))}=${obj[k]}`;
  File "/usr/odk/lib/model/query/users.js", line 71, col 9, in _getSql
    where ${equals(options.condition)} and actors."deletedAt" is null
  File "/usr/odk/lib/model/query/users.js", line 79, col 12, in <anonymous>
    maybeOne(_getSql(options.withCondition({ email }))).then(map(_unjoin));
  File "/usr/odk/lib/model/container.js", line 30, col 33, in Object.module.<computed> [as getByEmail]
    const result = fn(...args)(container);
  File "/usr/odk/lib/resources/users.js", line 47, col 11, in <anonymous>
    Users.getByEmail(body.email)
  File "/usr/odk/lib/http/endpoint.js", line 159, col 26, in <anonymous>
    .then((context) => resource(localContainer.with({ context }), context, request, response))
  File "/usr/odk/node_modules/slonik/dist/src/factories/createSqlTag.js", in runMicrotasks
  File "node:internal/process/task_queues", line 96, col 5, in processTicksAndRejections
  File "/usr/odk/node_modules/slonik/dist/src/connectionMethods/transaction.js", line 22, col 24, in Object.transaction
    const result = await handler(binders_1.bindTransactionConnection(log, connection, clientConfiguration, connection.connection.slonik. {snip}
  File "/usr/odk/node_modules/slonik/dist/src/factories/createConnection.js", line 97, col 18, in Object.createConnection
    result = await connectionHandler(connectionLog, connection, boundConnection, clientConfiguration);
dev-rahulbhadoriya pushed a commit to dev-rahulbhadoriya/central-backend that referenced this issue Dec 14, 2023
dev-rahulbhadoriya added a commit to dev-rahulbhadoriya/central-backend that referenced this issue Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant