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

Don't mention the schema when returning ResourceNotFound: #4372

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
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ResourcesTrialRoutesSpec extends BaseRouteSpec with ResourceInstanceFixtur
// Returns no validation result for myId for `schemas.resources`
case (StringSegment("myId") | IriSegment(`myId`), Some(IriSegment(schemas.resources))) =>
UIO.pure(NoValidation(projectRef))
case (IriSegment(iri), None) => IO.raiseError(ResourceNotFound(iri, project, None))
case (IriSegment(iri), None) => IO.raiseError(ResourceNotFound(iri, project))
case _ => IO.terminate(new IllegalStateException("Should not happen !"))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ object Resources {
def stateWhereResourceExists(c: ModifyCommand) = {
state match {
case None =>
IO.raiseError(ResourceNotFound(c.id, c.project, c.schemaOpt))
IO.raiseError(ResourceNotFound(c.id, c.project))
case Some(s) if s.rev != c.rev =>
IO.raiseError(IncorrectRev(c.rev, s.rev))
case Some(s) if c.schemaOpt.exists(cur => cur.iri != s.schema.iri) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ final class ResourcesImpl private (
projectContext <- fetchContext.onModify(projectRef)
iri <- expandIri(id, projectContext)
schemaRefOpt <- expandResourceRef(schemaOpt, projectContext)
resource <- log.stateOr(projectRef, iri, ResourceNotFound(iri, projectRef, schemaRefOpt))
resource <- log.stateOr(projectRef, iri, ResourceNotFound(iri, projectRef))
jsonld <- sourceParser(projectRef, projectContext, iri, resource.source)
res <- eval(RefreshResource(iri, projectRef, schemaRefOpt, jsonld, resource.rev, caller))
} yield res
Expand Down Expand Up @@ -145,7 +145,7 @@ final class ResourcesImpl private (
pc <- fetchContext.onRead(projectRef)
iri <- expandIri(id.value, pc)
schemaRefOpt <- expandResourceRef(schemaOpt, pc)
notFound = ResourceNotFound(iri, projectRef, schemaRefOpt)
notFound = ResourceNotFound(iri, projectRef)
state <- id match {
case Latest(_) => log.stateOr(projectRef, iri, notFound)
case Revision(_, rev) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ object ResourceRejection {
* the resource identifier
* @param project
* the project it belongs to
* @param schemaOpt
* the optional schema reference
*/
final case class ResourceNotFound(id: Iri, project: ProjectRef, schemaOpt: Option[ResourceRef])
final case class ResourceNotFound(id: Iri, project: ProjectRef)
extends ResourceFetchRejection(
s"Resource '$id' not found${schemaOpt.fold("")(schema => s" with schema '$schema'")} in project '$project'."
s"Resource '$id' not found in project '$project'."
)

/**
Expand Down Expand Up @@ -240,7 +238,7 @@ object ResourceRejection {
implicit val responseFieldsResources: HttpResponseFields[ResourceRejection] =
HttpResponseFields {
case RevisionNotFound(_, _) => StatusCodes.NotFound
case ResourceNotFound(_, _, _) => StatusCodes.NotFound
case ResourceNotFound(_, _) => StatusCodes.NotFound
case TagNotFound(_) => StatusCodes.NotFound
case InvalidSchemaRejection(_, _, _) => StatusCodes.NotFound
case ProjectContextRejection(rej) => rej.status
Expand Down