prismicio-community / ruby-kit

Community maintained development kit for Prismic and the Ruby language
https://prismic.io
Apache License 2.0
45 stars 35 forks source link

Bug: Release without description causes error in Prismic Ruby client #116

Closed faresd closed 1 year ago

faresd commented 2 years ago

If you create a Release without a description, which is possible by Publishing a document and choosing "Publish at a specific date and time", the ref returned by Prismic's API will have a null label and the Prismic client will fail to parse the entire response.

https://github.com/prismicio-community/ruby-kit/blob/1.7.0/lib/prismic/api.rb#L222

Found this in version 1.7.0, but still appears to be an issue on master. This line will fail with a "NoMethodError: undefined method `downcase' for nil:NilClass" ruby-kit/api.rb at 1.7.0 · prismicio-community/ruby-kit · GitHub 1

Versions

Reproduction

Additional Details https://community.prismic.io/t/release-without-description-causes-error-in-prismic-ruby-client/7514

Steps to reproduce

What is Expected?

What is actually happening?

faresd commented 2 years ago

I don't know Ruby, but basically, I think the fix would be something like thisref['label'].nil ? nil : ref['label']. downcase

bitboxer commented 2 years ago
ref['label']?.downcase

would be enough