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

Deleting a datasource_entry results in a JSON::ParseError from attempting to parse the empty string #34

Open
cykod opened this issue Jan 4, 2023 · 1 comment

Comments

@cykod
Copy link

cykod commented Jan 4, 2023

This likely happens on other DELETE requests, but I'm currently only running into it attempting to delete datasource_entries via the API.

Successfully calling DELETE on a datasource_entity results in a response code of 204 (No Content) and an empty body which presents as the empty string in rest-client. The API client then attempt to call JSON.parse on the empty string, which results in a thrown exception of JSON::ParserError (859: unexpected token at '') caused by the call at https://github.com/storyblok/storyblok-ruby/blob/1f018c0965f754d2ea47424dd5e5cc153c4a8404/lib/storyblok/client.rb#L174 which calls https://github.com/storyblok/storyblok-ruby/blob/1f018c0965f754d2ea47424dd5e5cc153c4a8404/lib/storyblok/client.rb#L226-L228
Regardless of the return value of the request.

We are on Ruby 2.7.6, but verified the behavior of JSON.parse("") on Ruby 3.2 and it's the same.


Expected Behavior

The API shouldn't attempt to parse the empty body

Current Behavior

The API ignores the lack of a response body and call JSON.parse regardless of the response code or the body.

Steps to Reproduce

  1. Use the Ruby client to delete a valid datasource_entry via the /v1/spaces/[SPACE_ID]/datasource_entries/[entry_id] route
  2. The client will trigger a unexpected token at '' (JSON::ParserError) exception
@cykod cykod changed the title Deleting a datasource_entry results in a JSON:ParseError from attempting to parse the empty string Deleting a datasource_entry results in a JSON::ParseError from attempting to parse the empty string Jan 4, 2023
@Djamal-Sadaghiani
Copy link

I am getting the same error when performing a put action for assets on (ruby 3.3.3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants