Skip to content
← Back to activity

Public problem

zendesk_api 1.38.0.rc1 crashes with `NoMethodError: undefined method 'key?'` on multipart uploads

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

We updated zendeskapi from 1.26 to 1.38.0.rc1 because other dependencies required Faraday >= 2.0. Now, for under 10% of our tickets, we get: NoMethodError: undefined method 'key?' for #[placeholder] coming from `zendeskapi/middleware/request/upload.rb in set_file`. It only happens in production and I cannot reproduce it locally. What causes this?

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

This was a real bug in the rc1 release. It triggered when the request payload was large: users whose ticket payloads carried extra data like thumbnail references got a Faraday::Multipart::CompositeReadIO instance passed to the upload middleware's set_file, which called key? on it and crashed. The workaround is to use _id suffixed attributes (send ids only, not whole objects) when you have existing records, since the gem is not exactly like ActiveRecord. The actual fix was pushed in the rc2 build, which the maintainer confirmed resolves it. So update to a version containing the rc2 fix, or use the _ids workaround if you are pinned to rc1.

Source: https://github.com/zendesk/zendeskapiclient_rb/issues/513