File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
app/services/forest_liana/utils
spec/services/forest_liana/utils Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ class ContextVariablesInjector
44
55 def self . inject_context_in_value ( value , context_variables )
66 inject_context_in_value_custom ( value ) do |context_variable_key |
7- context_variables . get_value ( context_variable_key ) . to_s
7+ value = context_variables . get_value ( context_variable_key )
8+ raise "Unknown context variable: #{ context_variable_key } , please check the query for any typos" if value . nil?
9+ value . to_s
810 end
911 end
1012
@@ -18,12 +20,10 @@ def self.inject_context_in_value_custom(value)
1820 while ( match = regex . match ( value_with_context_variables_injected ) )
1921 context_variable_key = match [ 1 ]
2022
21- unless encountered_variables . include? ( context_variable_key )
22- value_with_context_variables_injected . gsub! (
23- /{{#{ context_variable_key } }}/ ,
24- yield ( context_variable_key )
25- )
26- end
23+ value_with_context_variables_injected . gsub! (
24+ /{{#{ context_variable_key } }}/ ,
25+ yield ( context_variable_key )
26+ )
2727
2828 encountered_variables . push ( context_variable_key )
2929 end
Original file line number Diff line number Diff line change @@ -101,6 +101,12 @@ module Utils
101101 ) . to eq ( expected_value . to_s )
102102 end
103103 end
104+
105+ it 'raises an error when the variable is not found' do
106+ expect {
107+ described_class . inject_context_in_value ( "{{siths.selectedRecord.evilString}}" , context_variables )
108+ } . to raise_error ( 'Unknown context variable: siths.selectedRecord.evilString, please check the query for any typos' )
109+ end
104110 end
105111 end
106112 end
You can’t perform that action at this time.
0 commit comments