Skip to content

204 status code from API caused Unexpected end of JSON input error. #10792

@yevhenrudenko-ovpn

Description

@yevhenrudenko-ovpn

Component

c/v3-engine

What is the current behaviour?

I'm using OpenAPI connector which successfully interospects swagger-json schema. As the result, for DELETE rest API i have graphql mutation command which will delete some resource from server. In case of successfully deletion REST API returns 204 status code (Means no content in response body at all).
Hasura graphql engine failes with error when tries to parse response from this command.

What is the expected behaviour?

Hasura should not try to parse any data in case of 204 status code. 200/204 OK should be returned

How to reproduce the issue?

  1. Setup rest api which will return 204 status code
  2. Setup hasura openapi ddn connector
  3. Using hasura console, Execute mutation. -> 500 internal error will be received, but at the same time the resource will be deleted successfully.

Screenshots or Screencast

Please provide any traces or logs that could help here.

Stacktrace:
{"level":50,"time":1762510773066,"pid":19,"hostname":"b7ab1e8701ab","err":{"type":"InternalServerError","message":"Error encountered when invoking function 'DeleteResourceFunction'","stack":"Error: Error encountered when invoking function 'DeleteResourceFunction'\n at invokeFunction (/functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:184:13)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async executeMutationOperation (/functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:96:18)\n at async executeMutation (/functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:69:18)\n at async Object.mutation (/functions/node_modules/@hasura/ndc-lambda-sdk/src/connector.ts:67:14)\n at async Object. (/functions/node_modules/@hasura/ndc-sdk-typescript/src/server.ts:252:32)","statusCode":500,"details":{"type":"Object","message":"Unexpected end of JSON input","stack":"SyntaxError: Unexpected end of JSON input\n at JSON.parse ()\n at parseJSONFromBytes (node:internal/deps/undici/undici:5738:19)\n at successSteps (node:internal/deps/undici/undici:5719:27)\n at consumeBody (node:internal/deps/undici/undici:5725:9)\n at _Response.json (node:internal/deps/undici/undici:5665:18)\n at /functions/api.ts:1021:41\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async DeleteResourceFunction (/functions/functions.ts:910:18)\n at async /functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:176:16\n at async invokeFunction (/functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:172:12)\n"}},"msg":"Error encountered when invoking function 'DeleteResourceFunction'"}

Keywords

204 status code
No-Content
Unexpected end of JSON input

Metadata

Metadata

Assignees

No one assigned

    Labels

    k/v3-bugBug affecting Hasura v3 (DDN)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions