atlas_rb 1.8.4 → 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a319cfd0891ed913d8c08f8138d7e11cc12a3f13d79d1b41d9eab95a45e67824
4
- data.tar.gz: a840bfac145c02f79f59b53e226d293d90a89a18466511d4b9dbb9bd90460f59
3
+ metadata.gz: 6b34244827cff750075d39c45f1fd628840b6b1637a06f6bfefc876f285eafbe
4
+ data.tar.gz: d3f429989a1b983ed13a39c8363b17f1eff439d829f3694244327a38cfc2ca7e
5
5
  SHA512:
6
- metadata.gz: ba9b973ba96cbf0f132617bafe8d0475c0bba7b3f76328fbd54adfa20175c96f97fab5e6c4a66a025ea92890d3d2d90f00616674d143a7442dc10da763052013
7
- data.tar.gz: 0cc2ce817a804eb2925963f8aae21108bd4151e85cf437c0220574c067025a37544212dc298b2a97b197a063ac258ff8d759ee140f957e3e9ba10f7e3f6a15ce
6
+ metadata.gz: 70c4cce5eacaabca34495bee0cd8ed0ada54998e7a90f3b39b26b601d4d20be9e16355d64ac68e75fe39fce8f28d3e25e275d5627afd3644e296c18fdca3453e
7
+ data.tar.gz: b46212f70bfbec6a343654f89e73e33a13a372abb2e42ff0bf88a0a667d2d5033cee6e221dbdc63022b9feca6f0fd7000c12eb90172a76feaa11540696c04daa
data/.version CHANGED
@@ -1 +1 @@
1
- 1.8.4
1
+ 1.8.5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.5
4
+
5
+ ### Fixed — `find` returns a tombstone (`410`) instead of raising
6
+
7
+ The status-aware `find` (1.8.3) raised `AtlasRb::ResourceError` on any non-2xx
8
+ other than `404`. But Atlas returns a **tombstoned** resource as `410 Gone`
9
+ **with its full body** (carrying `tombstoned` / `tombstoned_at` / `tombstoned_by`)
10
+ — a "gone, but here it is" tombstone, not an error envelope. `fetch_resource`
11
+ now parses a `410` like a `2xx`, so every typed `find` (`Work` / `Collection` /
12
+ `Community` / `FileSet` / `Person` / `Compilation` / `Blob` / `Delegate` and the
13
+ polymorphic `Resource.find`) yields the tombstone rather than raising. Genuine
14
+ error statuses (400/401/403/422) still raise; a `404` still returns `nil`.
15
+
3
16
  ## 1.8.4
4
17
 
5
18
  ### Added — per-tier derivative-visibility policy (`Work.set_derivative_permissions`)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.8.4)
4
+ atlas_rb (1.8.5)
5
5
  faraday (~> 2.7)
6
6
  faraday-follow_redirects (~> 0.3.0)
7
7
  faraday-multipart (~> 1)
data/lib/atlas_rb/blob.rb CHANGED
@@ -29,7 +29,7 @@ module AtlasRb
29
29
  # held bytes — reconciliation compares this against the v1 manifest
30
30
  # without re-downloading), and a download URL — or `nil` when the Blob
31
31
  # does not exist (`404`).
32
- # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` (e.g. an
32
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
33
33
  # auth/validation error envelope), carrying Atlas's status + body.
34
34
  #
35
35
  # @example
@@ -24,7 +24,7 @@ module AtlasRb
24
24
  # omitted.
25
25
  # @return [Hash, nil] the `"collection"` object, already unwrapped from the
26
26
  # JSON response, or `nil` when the Collection does not exist (`404`).
27
- # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` (e.g. an
27
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
28
28
  # auth/validation error envelope), carrying Atlas's status + body.
29
29
  #
30
30
  # @example
@@ -25,7 +25,7 @@ module AtlasRb
25
25
  # omitted.
26
26
  # @return [Hash, nil] the `"community"` object from the JSON response,
27
27
  # already unwrapped, or `nil` when the Community does not exist (`404`).
28
- # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` (e.g. an
28
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
29
29
  # auth/validation error envelope), carrying Atlas's status + body.
30
30
  #
31
31
  # @example
@@ -33,7 +33,7 @@ module AtlasRb
33
33
  # includes `id`, `valkyrie_id`, `use`, `uri`, `mime_type`,
34
34
  # `original_filename`, `label`, and tombstone fields — or `nil` when the
35
35
  # Delegate does not exist (`404`).
36
- # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` (e.g. an
36
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
37
37
  # auth/validation error envelope), carrying Atlas's status + body.
38
38
  #
39
39
  # @example
@@ -235,7 +235,7 @@ module AtlasRb
235
235
  # Raised by the typed single-resource readers ({Resource.find} and the
236
236
  # `Work` / `Collection` / `Community` / `FileSet` / `Person` / `Compilation`
237
237
  # / `Blob` / `Delegate` overrides) when Atlas answers the `GET` with a
238
- # non-2xx that is **not** a `404` — i.e. an error envelope
238
+ # non-2xx that is **not** a `404` or a `410` — i.e. an error envelope
239
239
  # (`{ "error" => ... }`, status 400/401/403/422) on what the caller treated
240
240
  # as a plain read.
241
241
  #
@@ -249,7 +249,10 @@ module AtlasRb
249
249
  # attributable everywhere `find` is used.
250
250
  #
251
251
  # A genuine `404` is **not** this — it stays a clean `nil` return, since
252
- # "not found" is a normal `find` outcome callers already nil-check.
252
+ # "not found" is a normal `find` outcome callers already nil-check. A `410`
253
+ # is also **not** this — a tombstoned resource comes back as `410 Gone` with
254
+ # its full body, which `find` returns (the caller nil-checks / reads
255
+ # `tombstoned`), rather than an error to raise.
253
256
  #
254
257
  # @note Authorization failures on the narrow re-parent / linked-member /
255
258
  # Compilation write paths surface as {ForbiddenError} via
@@ -25,7 +25,7 @@ module AtlasRb
25
25
  # omitted.
26
26
  # @return [Hash, nil] the `"file_set"` object, already unwrapped, or `nil`
27
27
  # when the FileSet does not exist (`404`).
28
- # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` (e.g. an
28
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
29
29
  # auth/validation error envelope), carrying Atlas's status + body.
30
30
  #
31
31
  # @example
@@ -37,7 +37,7 @@ module AtlasRb
37
37
  # server-side `nuid` for callers that need it, e.g. depositor gating, and
38
38
  # `personal_root_id` for the publish-conduit parent), or `nil` when the
39
39
  # Person does not exist (`404`).
40
- # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` (e.g. an
40
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
41
41
  # auth/validation error envelope), carrying Atlas's status + body.
42
42
  def self.find(id, nuid: nil, on_behalf_of: nil)
43
43
  body = fetch_resource(ROUTE + id, nuid: nuid, on_behalf_of: on_behalf_of)
@@ -36,7 +36,7 @@ module AtlasRb
36
36
  # when the id resolves to nothing (`404`):
37
37
  # - `"klass"` — the resource type, capitalized (e.g. `"Work"`).
38
38
  # - `"resource"` — the resource payload as a Hash.
39
- # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` (e.g. an
39
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
40
40
  # auth/validation error envelope), carrying Atlas's status + body.
41
41
  #
42
42
  # @example Polymorphic lookup
@@ -260,6 +260,10 @@ module AtlasRb
260
260
  # - `404` → `nil` (clean "not found"; also avoids the
261
261
  # `JSON::ParserError` the old code raised on the empty `head :not_found`
262
262
  # body).
263
+ # - `410` → the parsed JSON Hash. A tombstoned resource is
264
+ # returned as `410 Gone` WITH its full body (carrying tombstoned /
265
+ # tombstoned_at / tombstoned_by), so it is a returnable tombstone, not an
266
+ # error envelope — `find` yields the tombstone rather than raising.
263
267
  # - any other non-2xx → {AtlasRb::ResourceError} carrying Atlas's status +
264
268
  # body, so the failure is attributable at the boundary.
265
269
  # - `2xx` → the parsed JSON Hash, for the caller to unwrap.
@@ -267,13 +271,19 @@ module AtlasRb
267
271
  # @param path [String] the resource path to GET (e.g. `"/works/abc123"`).
268
272
  # @param nuid [String, nil] optional acting user's NUID (see {find}).
269
273
  # @param on_behalf_of [String, nil] optional `On-Behalf-Of` NUID (see {find}).
270
- # @return [Hash, nil] the parsed JSON envelope, or `nil` on `404`.
271
- # @raise [AtlasRb::ResourceError] on any non-2xx other than `404`.
274
+ # @return [Hash, nil] the parsed JSON envelope (incl. a `410` tombstone), or
275
+ # `nil` on `404`.
276
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`.
272
277
  # @api private
273
278
  def self.fetch_resource(path, nuid: nil, on_behalf_of: nil)
274
279
  resp = connection({}, nuid, on_behalf_of: on_behalf_of).get(path)
275
280
  return nil if resp.status == 404
276
- unless resp.success?
281
+
282
+ # A tombstoned resource comes back as 410 Gone WITH its full body — a
283
+ # "gone, but here it is" tombstone, not an error envelope — so parse it
284
+ # like a 2xx and let callers read the tombstone. Only genuine error
285
+ # statuses raise.
286
+ unless resp.success? || resp.status == 410
277
287
  raise AtlasRb::ResourceError.new("GET #{path} → #{resp.status}: #{resp.body}", response: resp)
278
288
  end
279
289
 
data/lib/atlas_rb/work.rb CHANGED
@@ -24,7 +24,7 @@ module AtlasRb
24
24
  # {AtlasRb.config}.default_on_behalf_of when omitted.
25
25
  # @return [Hash, nil] the `"work"` object, already unwrapped from the JSON
26
26
  # response, or `nil` when the Work does not exist (`404`).
27
- # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` (e.g. an
27
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
28
28
  # auth/validation error envelope), carrying Atlas's status + body.
29
29
  #
30
30
  # @example
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlas_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.4
4
+ version: 1.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cliff