Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/4.0.1 #261

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 4.0.1 (2024-11-19)
--------------------------
Consider all `ClientFailure`s as not found in `lookupSchemasUntil` (#260)

Version 4.0.0 (2024-09-30)
--------------------------
Add caching to lookupSchemasUntil function (#258)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Iglu Scala Client is used extensively in **[Snowplow][snowplow-repo]** to valida

## Installation

The latest version of Iglu Scala Client is 4.0.0, which works with Scala 2.12, 2.13, and 3.
The latest version of Iglu Scala Client is 4.0.1, which works with Scala 2.12, 2.13, and 3.

If you're using SBT, add the following lines to your build file:

```scala
val igluClient = "com.snowplowanalytics" %% "iglu-scala-client" % "4.0.0"
val igluClient = "com.snowplowanalytics" %% "iglu-scala-client" % "4.0.1"
```

## API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,19 @@ final case class Resolver[F[_]](repos: List[Registry], cache: Option[ResolverCac
/**
* If Iglu Central or any of its mirrors doesn't have a schema,
* it should be considered NotFound, even if one of them returned an error.
* All 4xx (`ClientFailure`) are also considered NotFound.
*/
private[resolver] def isNotFound(error: ResolutionError): Boolean = {
val (igluCentral, custom) = error.value.partition { case (repo, _) =>
allIgluCentral.contains(repo)
}
(igluCentral.isEmpty || igluCentral.values.exists(
_.errors.exists(_ == RegistryError.NotFound)
)) && custom.values.flatMap(_.errors).forall(_ == RegistryError.NotFound)
_.errors.exists(e =>
e == RegistryError.NotFound || e.isInstanceOf[RegistryError.ClientFailure]
)
)) && custom.values
.flatMap(_.errors)
.forall(e => e == RegistryError.NotFound || e.isInstanceOf[RegistryError.ClientFailure])
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ class ResolverSpec extends Specification with CatsEffect {
result from SchemaListLike should contain the exact schemaKey provided $e13
isNotFound should
return true if custom repo and Iglu Central repos don't have a schema $e14
return true if one Iglu Central repo returns an error and the other one NotFound $e15
return false if custom repo returns an error $e16
return true if there is no custom repo, one Iglu Central repo returns an error and the other one NotFound $e17
return false if there is no custom repo and Iglu Central ones return an error $e18
return true if there is just one custom repo that returns NotFound $e19
return false if there is just one custom repo that returns an error $e20
return true if one Iglu Central repo returns 2 errors and the other one returns one error and one NotFound $e21
return true if one Iglu Central repo returns a RepoFailure and the other one NotFound $e15
return false if custom repo returns a RepoFailure $e16
return true if custom repo returns a ClientFailure $e17
return true if there is no custom repo, one Iglu Central repo returns an error and the other one NotFound $e18
return false if there is no custom repo and Iglu Central ones return a RepoFailure $e19
return true if there is no custom repo and Iglu Central ones return a ClientFailure $e20
return true if there is just one custom repo that returns NotFound $e21
return false if there is just one custom repo that returns a RepoFailure $e22
return true if there is just one custom repo that returns a ClientFailure $e23
return true if one Iglu Central repo returns 2 errors and the other one returns one error and one NotFound $e24
"""

import ResolverSpec._
Expand Down Expand Up @@ -556,7 +559,7 @@ class ResolverSpec extends Specification with CatsEffect {
Instant.now()
),
Repos.custom.config.name -> LookupHistory(
Set(RegistryError.ClientFailure("Something went wrong")),
Set(RegistryError.RepoFailure("Something went wrong")),
1,
Instant.now()
)
Expand All @@ -567,6 +570,34 @@ class ResolverSpec extends Specification with CatsEffect {
}

def e17 = {
val resolver: Resolver[Id] =
Resolver
.init[Id](0, None, SpecHelpers.IgluCentral, SpecHelpers.IgluCentralMirror, Repos.custom)

val resolutionError = ResolutionError(
SortedMap(
SpecHelpers.IgluCentral.config.name -> LookupHistory(
Set(RegistryError.NotFound),
1,
Instant.now()
),
SpecHelpers.IgluCentralMirror.config.name -> LookupHistory(
Set(RegistryError.NotFound),
1,
Instant.now()
),
Repos.custom.config.name -> LookupHistory(
Set(RegistryError.ClientFailure("402")),
1,
Instant.now()
)
)
)

resolver.isNotFound(resolutionError) should beTrue
}

def e18 = {
val resolver: Resolver[Id] =
Resolver.init[Id](0, None, SpecHelpers.IgluCentral, SpecHelpers.IgluCentralMirror)

Expand All @@ -588,7 +619,7 @@ class ResolverSpec extends Specification with CatsEffect {
resolver.isNotFound(resolutionError) should beTrue
}

def e18 = {
def e19 = {
val resolver: Resolver[Id] =
Resolver.init[Id](0, None, SpecHelpers.IgluCentral, SpecHelpers.IgluCentralMirror)

Expand All @@ -600,7 +631,7 @@ class ResolverSpec extends Specification with CatsEffect {
Instant.now()
),
SpecHelpers.IgluCentralMirror.config.name -> LookupHistory(
Set(RegistryError.ClientFailure("Network issue")),
Set(RegistryError.RepoFailure("Network issue")),
1,
Instant.now()
)
Expand All @@ -610,7 +641,29 @@ class ResolverSpec extends Specification with CatsEffect {
resolver.isNotFound(resolutionError) should beFalse
}

def e19 = {
def e20 = {
val resolver: Resolver[Id] =
Resolver.init[Id](0, None, SpecHelpers.IgluCentral, SpecHelpers.IgluCentralMirror)

val resolutionError = ResolutionError(
SortedMap(
SpecHelpers.IgluCentral.config.name -> LookupHistory(
Set(RegistryError.RepoFailure("Problem")),
1,
Instant.now()
),
SpecHelpers.IgluCentralMirror.config.name -> LookupHistory(
Set(RegistryError.ClientFailure("403 Forbidden")),
1,
Instant.now()
)
)
)

resolver.isNotFound(resolutionError) should beTrue
}

def e21 = {
val resolver: Resolver[Id] =
Resolver.init[Id](0, None, Repos.custom)

Expand All @@ -623,14 +676,14 @@ class ResolverSpec extends Specification with CatsEffect {
resolver.isNotFound(resolutionError) should beTrue
}

def e20 = {
def e22 = {
val resolver: Resolver[Id] =
Resolver.init[Id](0, None, Repos.custom)

val resolutionError = ResolutionError(
SortedMap(
Repos.custom.config.name -> LookupHistory(
Set(RegistryError.ClientFailure("Boom")),
Set(RegistryError.RepoFailure("Boom")),
1,
Instant.now()
)
Expand All @@ -640,7 +693,24 @@ class ResolverSpec extends Specification with CatsEffect {
resolver.isNotFound(resolutionError) should beFalse
}

def e21 = {
def e23 = {
val resolver: Resolver[Id] =
Resolver.init[Id](0, None, Repos.custom)

val resolutionError = ResolutionError(
SortedMap(
Repos.custom.config.name -> LookupHistory(
Set(RegistryError.ClientFailure("401")),
1,
Instant.now()
)
)
)

resolver.isNotFound(resolutionError) should beTrue
}

def e24 = {
val resolver: Resolver[Id] =
Resolver
.init[Id](0, None, SpecHelpers.IgluCentral, SpecHelpers.IgluCentralMirror, Repos.custom)
Expand Down
Loading