Skip to content

[DISCO-4084] Handle 204 as a successful empty response#7331

Merged
misaniwere merged 2 commits intomainfrom
DISCO-4084
Apr 20, 2026
Merged

[DISCO-4084] Handle 204 as a successful empty response#7331
misaniwere merged 2 commits intomainfrom
DISCO-4084

Conversation

@misaniwere
Copy link
Copy Markdown
Contributor

[DISCO-4084]

The client was previously treating HTTP 204 as an error. 204 is a valid Merino API response indicating no suggestions are available for weather. getSuggestions() now returns Option<String> —> None for 204 and Some(json) for 200. The internal NoContent error variant has been removed.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@misaniwere misaniwere requested a review from a team April 20, 2026 14:26
Copy link
Copy Markdown
Member

@gruberb gruberb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some food for thought. I think it's easier to keep the codes on the top level.

code: status,
message,
}),
200 => Ok(Some(response)),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to keep the error codes on the top level, for readability. The performance cost for unwrapping the .text() is very low here, and we could even do:

 match status {
      200 => Ok(Some(response)),
      204 => Ok(None),
      400 => Err(Error::BadRequest { code: status, message: response.text().to_string() }),
      422 => Err(Error::Validation { code: status, message: response.text().to_string() }),
      500..=599 => Err(Error::Server { code: status, message: response.text().to_string() }),
      _ => Err(Error::Unexpected { code: status, message: response.text().to_string() }),
  }

@misaniwere misaniwere added this pull request to the merge queue Apr 20, 2026
Merged via the queue into main with commit 6385a87 Apr 20, 2026
14 checks passed
@misaniwere misaniwere deleted the DISCO-4084 branch April 20, 2026 17:38
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

Successfully merging this pull request may close these issues.

2 participants