forest_admin_agent 1.11.3 → 1.11.4

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: 7d67a8ff1322804a804bc7b39cb8b67e81e0330a152ae494c94d63dc18dc52fc
4
- data.tar.gz: 30f741c203010746a15adcea8b7250be4d7bb17af08832ee4abe9fc7bf0ede2f
3
+ metadata.gz: 880be64494226c28b53e647394e4ebab643eb4194256c22a4ee344bfe1805f2a
4
+ data.tar.gz: fd62a8c9511edf02d5dda971a7db8d5645c7ed428bc550c3a5f4c3d54a8254d1
5
5
  SHA512:
6
- metadata.gz: 6c3c8a138807db54fc687bda815d9ebcb0bf654f3de3e95141125e1ff18b160127089ac0b85299d6754518c258efb8c4066e72c5f6467bda4ff008a6e647e705
7
- data.tar.gz: 3149d5eee9eb4338ca990c5bac6bb8168432de9b48ada3c274d079d2c9b85d18e8cb6dafda81237c1be9676ee610518846968f15b459a8552c9f73a45a9a7d1d
6
+ metadata.gz: 448718e9e014c4a84d8554c90224437bcba502231bb5583a38a7ff30d5518005e7799765f6091a9cfe0451551b93f14efc0aee449f194a693ed4a3c48632c306
7
+ data.tar.gz: c5de0220f60301249a2f8c4fff27a4154f2e1df49fbcc39ac369bce6f4633ad47fe32c314ca84b56a4406e057b323180def3242f42c3441ee4f68cc6ef6e4091
@@ -37,7 +37,7 @@ module ForestAdminAgent
37
37
 
38
38
  def can_approve?
39
39
  if smart_action[:userApprovalEnabled].include?(role_id) &&
40
- (condition_by_role_id(smart_action[:userApprovalConditions]).blank? || match_conditions(:userApprovalConditions)) &&
40
+ (condition_by_role_id(smart_action[:userApprovalConditions]).nil? || match_conditions(:userApprovalConditions)) &&
41
41
  (attributes[:signed_approval_request][:data][:attributes][:requester_id] != caller.id ||
42
42
  smart_action[:selfApprovalEnabled].include?(role_id))
43
43
  return true
@@ -48,17 +48,17 @@ module ForestAdminAgent
48
48
 
49
49
  def can_trigger?
50
50
  if smart_action[:triggerEnabled].include?(role_id) && !smart_action[:approvalRequired].include?(role_id)
51
- if condition_by_role_id(smart_action[:triggerConditions]).blank? || match_conditions(:triggerConditions)
51
+ if condition_by_role_id(smart_action[:triggerConditions]).nil? || match_conditions(:triggerConditions)
52
52
  return true
53
53
  end
54
54
  elsif smart_action[:approvalRequired].include?(role_id) && smart_action[:triggerEnabled].include?(role_id)
55
- if condition_by_role_id(smart_action[:approvalRequiredConditions]).blank? || match_conditions(:approvalRequiredConditions)
55
+ if condition_by_role_id(smart_action[:approvalRequiredConditions]).nil? || match_conditions(:approvalRequiredConditions)
56
56
  raise RequireApproval.new(
57
57
  'This action requires to be approved.',
58
58
  REQUIRE_APPROVAL_ERROR,
59
59
  smart_action[:userApprovalEnabled]
60
60
  )
61
- elsif condition_by_role_id(smart_action[:triggerConditions]).blank? || match_conditions(:triggerConditions)
61
+ elsif condition_by_role_id(smart_action[:triggerConditions]).nil? || match_conditions(:triggerConditions)
62
62
  return true
63
63
  end
64
64
  end
@@ -67,7 +67,21 @@ module ForestAdminAgent
67
67
  end
68
68
 
69
69
  def match_conditions(condition_name)
70
- pk = Schema.primary_keys(collection)[0]
70
+ pks = Schema.primary_keys(collection)
71
+
72
+ if pks.nil? || pks.empty?
73
+ ForestAdminAgent::Facades::Container.logger.log(
74
+ 'Error',
75
+ "Missing primary keys for action with conditional permissions - Collection: #{collection.name}, " \
76
+ "Action: #{attributes[:smart_action_id]}"
77
+ )
78
+
79
+ raise ForestAdminDatasourceToolkit::Exceptions::ForestException,
80
+ "Collection '#{collection.name}' has no primary keys. " \
81
+ 'Actions with conditional permissions require a primary key to identify records.'
82
+ end
83
+
84
+ pk = pks[0]
71
85
  condition_filter = if attributes[:all_records]
72
86
  Nodes::ConditionTreeLeaf.new(pk, 'NOT_EQUAL', attributes[:all_records_ids_excluded])
73
87
  else
@@ -86,7 +100,28 @@ module ForestAdminAgent
86
100
 
87
101
  rows = collection.aggregate(caller, conditional_filter, Aggregation.new(operation: 'Count'))
88
102
  (rows.empty? ? 0 : rows[0]['value']) == attributes[:ids].count
89
- rescue StandardError
103
+ rescue ForestAdminDatasourceToolkit::Exceptions::ForestException => e
104
+ # Let primary key validation errors propagate - these are actionable schema issues
105
+ # Wrap other ForestExceptions (like invalid operators) in ConflictError
106
+ raise if e.message.include?('has no primary keys')
107
+
108
+ raise ConflictError.new(
109
+ 'The conditions to trigger this action cannot be verified. Please contact an administrator.',
110
+ INVALID_ACTION_CONDITION_ERROR
111
+ )
112
+ rescue ArgumentError, TypeError => e
113
+ # Catch specific errors from condition parsing/validation
114
+ raise ConflictError.new(
115
+ "Invalid action condition: #{e.message}. Please contact an administrator.",
116
+ INVALID_ACTION_CONDITION_ERROR
117
+ )
118
+ rescue StandardError => e
119
+ # Catch unexpected errors and log for debugging
120
+ ForestAdminAgent::Facades::Container.logger.log(
121
+ 'Error',
122
+ "Unexpected error in match_conditions: #{e.class} - #{e.message}"
123
+ )
124
+
90
125
  raise ConflictError.new(
91
126
  'The conditions to trigger this action cannot be verified. Please contact an administrator.',
92
127
  INVALID_ACTION_CONDITION_ERROR
@@ -6,7 +6,7 @@ module ForestAdminAgent
6
6
  module Schema
7
7
  class SchemaEmitter
8
8
  LIANA_NAME = "agent-ruby"
9
- LIANA_VERSION = "1.11.3"
9
+ LIANA_VERSION = "1.11.4"
10
10
 
11
11
  def self.generate(datasource)
12
12
  datasource.collections
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.11.3"
2
+ VERSION = "1.11.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.3
4
+ version: 1.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu