Skip to content

Client#post and #delete don't rescue 404 from tapas-xq #52

@candyhazlett

Description

@candyhazlett

Background

As of tapas-xq PR #31, several endpoints that previously returned 500 for a missing document now correctly return HTTP 404 instead. This affects:

  • POST /:project-id/:doc-id/mods — store MODS (doc must exist first)
  • POST /:project-id/:doc-id/tfe — store TFE (doc must exist first)
  • DELETE /:project-id/:doc-id — delete core file
  • DELETE /:project-id — delete project documents

Problem

TapasXq::Client#get already rescues RestClient::NotFound and raises TapasXq::NotFoundError. However, #post and #delete do not rescue 404. A 404 from either method falls through to handle_error_response, which raises the generic:

TapasXq::InvalidResponseError: "Unexpected status code: 404"

This means callers cannot distinguish "document not found" from other unexpected errors, and the processing_error stored on CoreFile is unhelpfully generic.

Suggested fix

app/services/tapas_xq/client.rb — add 404 rescue to #post and #delete:

rescue RestClient::NotFound
  raise TapasXq::NotFoundError, "Resource not found"

This is already the pattern used in #get.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions