From afb78e9ec8ed230c550d3b66ca66aaf41fc7360d Mon Sep 17 00:00:00 2001 From: Albert T Date: Sat, 24 Oct 2026 22:55:02 -0400 Subject: [PATCH 1/2] [NOTE-1714] fix: treat 207 Multi-Status responses as success The Notetaker media endpoint returns 207 when some requested media (for example the summary) failed but the rest is available. The body carries the available media plus an `errors` list. HTTP_SUCCESS_CODES did not include 207, so download_media raised a NylasApiError and the caller lost the working recording URL. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CEuUhrasuRFEFW6KcTW7QN --- CHANGELOG.md | 1 + lib/nylas/errors.rb | 2 +- spec/nylas/handler/http_client_spec.rb | 28 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23f50a31..d43f27fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ### Unreleased +* Fixed `Notetakers#download_media` raising an error when the API returns 207 Multi-Status. A 207 is now treated as success, so the media that is available and the `errors` list are returned * Documented `tracking_options.domain_name` hash support for custom link and open tracking hostnames. See the [message tracking documentation](https://developer.nylas.com/docs/v3/email/message-tracking/) * Documented Contact `metadata` and `metadata_pair` hashes, and added `contact.updated` and `contact.deleted` webhook trigger constants diff --git a/lib/nylas/errors.rb b/lib/nylas/errors.rb index ebb14f86..a72eafdc 100644 --- a/lib/nylas/errors.rb +++ b/lib/nylas/errors.rb @@ -83,5 +83,5 @@ def initialize(url, timeout) end end - HTTP_SUCCESS_CODES = [200, 201, 202, 302].freeze + HTTP_SUCCESS_CODES = [200, 201, 202, 207, 302].freeze end diff --git a/spec/nylas/handler/http_client_spec.rb b/spec/nylas/handler/http_client_spec.rb index 2d39db42..a47bbb1f 100644 --- a/spec/nylas/handler/http_client_spec.rb +++ b/spec/nylas/handler/http_client_spec.rb @@ -704,6 +704,21 @@ class TestHttpClient "https://test.api.nylas.com/foo") end.not_to raise_error end + + it "does not raise an error for a 207 Multi-Status response" do + response = { + request_id: "request-id", + data: { + recording: { url: "https://test.storage/recording.mp4" }, + errors: [{ artifact: "summary", code: "generation_failed" }] + } + } + + expect do + http_client.send(:handle_failed_response, 207, response, + "https://test.api.nylas.com/foo") + end.not_to raise_error + end end describe "#parse_json_evaluate_error" do @@ -719,6 +734,19 @@ class TestHttpClient "https://test.api.nylas.com/foo", "application/json")).to eq(response) end + it "returns the parsed response for a 207 Multi-Status response" do + response = { + request_id: "request-id", + data: { + recording: { url: "https://test.storage/recording.mp4" }, + errors: [{ artifact: "summary", code: "generation_failed" }] + } + } + + expect(http_client.send(:parse_json_evaluate_error, 207, response.to_json, + "https://test.api.nylas.com/foo", "application/json")).to eq(response) + end + it "raises a Nylas::JsonParseError if the response is not valid JSON" do response = "foo" From eb3b8096956a93903ee042145f827d1731723d5e Mon Sep 17 00:00:00 2001 From: Albert T Date: Sat, 24 Oct 2026 22:59:14 -0400 Subject: [PATCH 2/2] [NOTE-1714] docs: reword changelog entry for 207 support Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CEuUhrasuRFEFW6KcTW7QN --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d43f27fc..8910c0c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ### Unreleased -* Fixed `Notetakers#download_media` raising an error when the API returns 207 Multi-Status. A 207 is now treated as success, so the media that is available and the `errors` list are returned +* Treat 207 Multi-Status responses as successful, so a response that carries partial results is returned instead of raising an error * Documented `tracking_options.domain_name` hash support for custom link and open tracking hostnames. See the [message tracking documentation](https://developer.nylas.com/docs/v3/email/message-tracking/) * Documented Contact `metadata` and `metadata_pair` hashes, and added `contact.updated` and `contact.deleted` webhook trigger constants