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

N8N - API api/v1/executions => application crashes #5249

Closed
stephanerigaux-atos opened this issue Jan 25, 2023 · 6 comments · Fixed by #5251 or #5252
Closed

N8N - API api/v1/executions => application crashes #5249

stephanerigaux-atos opened this issue Jan 25, 2023 · 6 comments · Fixed by #5251 or #5252
Labels
in linear Issue or PR has been created in Linear for internal review

Comments

@stephanerigaux-atos
Copy link

stephanerigaux-atos commented Jan 25, 2023

Describe the bug
After try the N8N api, we found a bug on api/v1/executions endpoint.

To Reproduce
Steps to reproduce the behavior:

  1. Go to API Playground
  2. Click on GET /executions/{id}
  3. Scroll down to id field to fill en NAN value (exemple : toto, undefined, 123er)
  4. Click on Execute button
  5. In response panel, we get

66b7a7de-757b-44a6-8632-e6fc79a09e0c

  1. In docker log for the n8n container, we can see :
hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: "unnamed portal parameter $1 = '...'",
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'numutils.c',
  line: '320',
  routine: 'pg_strtoint32'
}
Last session crashed
n8n ready on 0.0.0.0, port 5678
Version: 0.212.0 Editor is now accessible via:http://localhost:5678/
/usr/local/lib/node_modules/n8n/dist/ErrorReporting.js:59
            throw error;
            ^ QueryFailedError: invalid input syntax for type integer: "NaN"
    at PostgresQueryRunner.query (/usr/local/lib/node_modules/n8n/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at SelectQueryBuilder.loadRawResults (/usr/local/lib/node_modules/n8n/node_modules/typeorm/query-builder/SelectQueryBuilder.js:2132:25)
    at SelectQueryBuilder.executeEntitiesAndRawResults (/usr/local/lib/node_modules/n8n/node_modules/typeorm/query-builder/SelectQueryBuilder.js:1992:26)
    at SelectQueryBuilder.getRawAndEntities (/usr/local/lib/node_modules/n8n/node_modules/typeorm/query-builder/SelectQueryBuilder.js:667:29)
    at SelectQueryBuilder.getOne (/usr/local/lib/node_modules/n8n/node_modules/typeorm/query-builder/SelectQueryBuilder.js:694:25)
    at getExecutionInWorkflows (/usr/local/lib/node_modules/n8n/dist/PublicApi/v1/handlers/executions/executions.service.js:114:23)
    at module.exports.getExecution (/usr/local/lib/node_modules/n8n/dist/PublicApi/v1/handlers/executions/executions.handler.js:60:31)
Emitted 'error' event on Domain instance at:
    at emit (node:internal/process/promises:138:33)
    at processPromiseRejections (node:internal/process/promises:274:27)
    at processTicksAndRejections (node:internal/process/task_queues:97:32) {
  query: 'SELECT "ExecutionEntity"."id" AS "ExecutionEntity_id", "ExecutionEntity"."finished" AS "ExecutionEntity_finished", "ExecutionEntity"."mode" AS "ExecutionEntity_mode", "ExecutionEntity"."retryOf" AS "ExecutionEntity_retryOf", "ExecutionEntity"."retrySuccessId" AS "ExecutionEntity_retrySuccessId", "ExecutionEntity"."startedAt" AS "ExecutionEntity_startedAt", "ExecutionEntity"."stoppedAt" AS "ExecutionEntity_stoppedAt", "ExecutionEntity"."workflowId" AS "ExecutionEntity_workflowId", "ExecutionEntity"."waitTill" AS "ExecutionEntity_waitTill" FROM "public"."execution_entity" "ExecutionEntity" WHERE ("ExecutionEntity"."id" = $1 AND "ExecutionEntity"."workflowId" IN ($2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29)) LIMIT 1',
  parameters: [
    NaN,  '1',  '2',  '3',  '5',
    '6',  '11', '12', '13', '14',
    '15', '16', '17', '18', '19',
    '20', '21', '22', '23', '24',
    '25', '26', '27', '28', '29',
    '30', '31', '32', '33'
  ],
  driverError: error: invalid input syntax for type integer: "NaN"
      at Parser.parseErrorMessage (/usr/local/lib/node_modules/n8n/node_modules/pg-protocol/dist/parser.js:287:98)
  1. The container restarts automatically, N8N is up and after api request , N8N crashes again.

Expected behavior
The api should respond an http response 400 and not crash the application in entire.

Environment (please complete the following information):

  • OS: Red Hat Enterprise Linux Server release 7.5 (Maipo)
  • n8n : Version : 0.212.0 (docker version)
  • Node.js Version : v16.18.1
  • Database system : PostgreSQL 14.5 (Debian 14.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
  • Operation mode : own

Additional context
n/a

@Joffcom
Copy link
Member

Joffcom commented Jan 25, 2023

Hey @stephanerigaux-atos,

Thanks for reporting this one, You mentioned that it crashes in loop but in my test it just crashed the once which is still not ideal and needs fixing.

I have created an internal ticket for this one which we will be tracking as N8N-6047.

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Jan 25, 2023
@stephanerigaux-atos
Copy link
Author

stephanerigaux-atos commented Jan 25, 2023 via email

@Joffcom
Copy link
Member

Joffcom commented Jan 25, 2023

Hi @stephanerigaux-atos,

Perfect thanks for confirming.

@stephanerigaux-atos
Copy link
Author

Hi,

Thank you for the fix. We saw the same issue with the api to get the workflows list . The fix is global for all api endpoints ?

@netroy netroy added the Upcoming Release Will be part of the upcoming release label Jan 26, 2023
@netroy
Copy link
Member

netroy commented Jan 26, 2023

@stephanerigaux-atos Yes, the fix should should add the correct validation for all numeric IDs in the public API.
This second fix should also prevent the service from crashing on unhandled errors in the public API, and return a 500 instead.

@janober
Copy link
Member

janober commented Jan 27, 2023

Fix got released with [email protected]

@janober janober removed the Upcoming Release Will be part of the upcoming release label Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review
Projects
None yet
4 participants