Skip to content

bug: (client sdks) 204 responses fail validation with --enable-runtime-response-validation #285

@mnahkies

Description

@mnahkies

clients generated with --enable-runtime-response-validation try to validate empty responses, such as a 204 as being undefined, eg: z.undefined().

unfortunately axios actually returns an empty string "" instead of undefined, and thus the runtime validation fails, whilst fetch chokes on SyntaxError: Unexpected end of JSON input when calling .json()

Workarounds

  • For axios we can workaround by using a response interceptor for axios that converts "" to undefined
  • For fetch we should simply not call json() if the status code is 204

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions