jpie 4.1.8 → 4.1.9

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: d42b5ce17662c2c8b8562e0948d6bba493823a9cd65e1d43ce79c2864d395a38
4
- data.tar.gz: f968fca6f255f5949a20f1e2a99f70f34f9e3e620dd6e71dad16348e136cb48f
3
+ metadata.gz: 315aaaaed71bdf4807a63a407205327316ad7739e269c1179a27e0d801b51483
4
+ data.tar.gz: 829e98cab64b8b6794a3fa389f62d1a179746685f2af3803efd40e215e15024e
5
5
  SHA512:
6
- metadata.gz: '093d9ab5bc2c337b7a8829aa7918fc6b174d7db815ec87b14b7460dbd41cd2c44e1da755d47c569314bbd4838b3b0c53b8ef9159508599035d42e1341b392ca1'
7
- data.tar.gz: f3c12becc5f46da8061360f859d4b49e50f63ca6e3a4a2c4b720959c3969b8cb09c31c34281019f2cc5245ab9276a9bd02d7aeb954fc3325ba72fb1b49d592fa
6
+ metadata.gz: aa206b22a633084e2b8585bcc1f7154e6753bb9f46cd2439b703df8451eb51e2de7db1fc70120fa65f1c7293054d751f6ea5694f7e247ded43f1b6cc33250629
7
+ data.tar.gz: 025d1cef8a720347a0f453f5ec2c73c785c276996b92574f1785bed0316b22d77c9077b5aaa24dad78ceb08b0bdda4465ffb242eb9f0c99e6cb5053e62863e8b
data/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ at release time.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [4.1.9] - 2026-11-20
11
+
12
+ ### Fixed
13
+
14
+ - **Refuse a write body that names a hidden target.** In 4.1.8 a write body that
15
+ named a target hidden by `authorization_scope` set the key to nil. An update
16
+ then cleared the stored relationship and answered 200. The write now stops
17
+ with 400, as a relationship route does for a hidden target or a missing
18
+ target. Regression spec: `authorization_scope_body_write_target_spec.rb`.
19
+
10
20
  ## [4.1.8] - 2026-11-20
11
21
 
12
22
  ### Fixed
@@ -64,7 +64,7 @@ module JSONAPI
64
64
  target = model_class || self.model_class
65
65
  payload = data.nil? ? raw_jsonapi_data : symbolize_data(data)
66
66
  attrs = JSONAPI::Deserializer.new(payload, model_class: target, action:, definition:).to_model_attributes
67
- JSONAPI::ResourceIdentifier.withhold_hidden_targets(attrs, target, self)
67
+ JSONAPI::ResourceIdentifier.reject_hidden_targets(attrs, target, self)
68
68
  end
69
69
 
70
70
  def resource_url(resource)
@@ -35,16 +35,18 @@ module JSONAPI
35
35
  end
36
36
 
37
37
  # A write body assigns the raw foreign key and leaves the lookup to the model. A target the
38
- # caller's scope hides must act like a target that does not exist. So the key becomes nil, and
39
- # the model answers the same for a hidden id and a missing id.
40
- def withhold_hidden_targets(attrs, model_class, controller)
38
+ # caller's scope hides must fail like a target that does not exist, as it does on a
39
+ # relationship route. The write stops, so it never clears the stored relationship.
40
+ def reject_hidden_targets(attrs, model_class, controller)
41
41
  return attrs unless controller && JSONAPI.configuration.authorization_scope
42
42
 
43
43
  model_class.reflect_on_all_associations(:belongs_to).each do |association|
44
44
  next if association.polymorphic?
45
45
 
46
- key = association.foreign_key.to_s
47
- attrs[key] = nil unless attrs[key].nil? || visible_target?(association, attrs[key], controller)
46
+ id = attrs[association.foreign_key.to_s]
47
+ next if id.nil? || visible_target?(association, id, controller)
48
+
49
+ raise ArgumentError, "Related resource not found: #{association.name} with id #{id}"
48
50
  end
49
51
  attrs
50
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSONAPI
4
- VERSION = "4.1.8"
4
+ VERSION = "4.1.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jpie
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.8
4
+ version: 4.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Kampp