@@ -55,6 +55,7 @@ def handle_before_submit_prompt(ctx: typer.Context, payload: AIHookPayload, poli
5555 scan_id = None
5656 block_reason = None
5757 outcome = AIHookOutcome .ALLOWED
58+ error_message = None
5859
5960 try :
6061 violation_summary , scan_id = _scan_text_for_secrets (ctx , clipped , timeout_ms )
@@ -72,6 +73,7 @@ def handle_before_submit_prompt(ctx: typer.Context, payload: AIHookPayload, poli
7273 AIHookOutcome .ALLOWED if get_policy_value (policy , 'fail_open' , default = True ) else AIHookOutcome .BLOCKED
7374 )
7475 block_reason = BlockReason .SCAN_FAILURE
76+ error_message = str (e )
7577 raise e
7678 finally :
7779 ai_client .create_event (
@@ -80,6 +82,7 @@ def handle_before_submit_prompt(ctx: typer.Context, payload: AIHookPayload, poli
8082 outcome ,
8183 scan_id = scan_id ,
8284 block_reason = block_reason ,
85+ error_message = error_message ,
8386 )
8487
8588
@@ -107,6 +110,7 @@ def handle_before_read_file(ctx: typer.Context, payload: AIHookPayload, policy:
107110 scan_id = None
108111 block_reason = None
109112 outcome = AIHookOutcome .ALLOWED
113+ error_message = None
110114
111115 try :
112116 # Check path-based denylist first
@@ -154,6 +158,7 @@ def handle_before_read_file(ctx: typer.Context, payload: AIHookPayload, policy:
154158 AIHookOutcome .ALLOWED if get_policy_value (policy , 'fail_open' , default = True ) else AIHookOutcome .BLOCKED
155159 )
156160 block_reason = BlockReason .SCAN_FAILURE
161+ error_message = str (e )
157162 raise e
158163 finally :
159164 ai_client .create_event (
@@ -162,6 +167,7 @@ def handle_before_read_file(ctx: typer.Context, payload: AIHookPayload, policy:
162167 outcome ,
163168 scan_id = scan_id ,
164169 block_reason = block_reason ,
170+ error_message = error_message ,
165171 )
166172
167173
@@ -195,6 +201,7 @@ def handle_before_mcp_execution(ctx: typer.Context, payload: AIHookPayload, poli
195201 scan_id = None
196202 block_reason = None
197203 outcome = AIHookOutcome .ALLOWED
204+ error_message = None
198205
199206 try :
200207 if get_policy_value (mcp_config , 'scan_arguments' , default = True ):
@@ -220,6 +227,7 @@ def handle_before_mcp_execution(ctx: typer.Context, payload: AIHookPayload, poli
220227 AIHookOutcome .ALLOWED if get_policy_value (policy , 'fail_open' , default = True ) else AIHookOutcome .BLOCKED
221228 )
222229 block_reason = BlockReason .SCAN_FAILURE
230+ error_message = str (e )
223231 raise e
224232 finally :
225233 ai_client .create_event (
@@ -228,6 +236,7 @@ def handle_before_mcp_execution(ctx: typer.Context, payload: AIHookPayload, poli
228236 outcome ,
229237 scan_id = scan_id ,
230238 block_reason = block_reason ,
239+ error_message = error_message ,
231240 )
232241
233242
0 commit comments