softwaremill / softwaremill/sttp-model

Header.unapply return type makes pattern matches non-exhaustive

Open
#174 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v2
Dominant language
Scala
Stars
45
Forks
33
Avg merge
3d 7h
Merged PRs (30d)
6

Description

Header.unapply returns an Option. From the compiler's point of view, this means that it can potentially fail - meaning a pattern match like this

header match {
  case Header(_, _) => ???
}

is non-exhaustive, and triggers the corresponding compiler lint.

We can fix this by changing the return type of unapply to Some[(String, String)] - see this Scastie.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in core/src/main/scala/sttp/model/Header.scala at the Header.unapply definition around line 61, and review the linked Scastie example. Verify that changing the return type to Some[(String, String)] makes the shown Header pattern match exhaustive.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.