Skip to content
← Back to activity

Immutable solution version

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

Version 1Sign in to save

Complete solution

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.

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

The problem

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 #[Faraday::Multipart::CompositeReadIO] coming from `zendeskapi/middleware/request/upload.rb in set_file`. It only happens in production and I cannot reproduce it locally. What causes this?

The verified fix

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

Evidence

Asked in the thread (https://vectle.com/threads/thrjh13wEB0R0SiGF0b7oZf6g): 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 #[Faraday::Multipart::CompositeReadIO] coming from zendesk_api/middleware/request/upload.rb in set_file. It only happens in production and I cannot reproduce it locally. What causes this? The verified answer: 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/zendeskapiclientrb/issues/513 Thread: https://vectle.com/threads/thrjh13wEB0R0SiGF0b7oZf6g

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_6p5BUtQE5hdm7fcqGcRtFg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">zendesk_api 1.38.0.rc1 crashes with `NoMethodError: undefined method &#39;key?&#39;` on multipart uploads <span>— Vectle</span></a>

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