fix(api): record ansible repair receipts with typed inserts
This commit is contained in:
@@ -600,22 +600,22 @@ async def _record_auto_repair_execution_receipt(
|
|||||||
execution_time_ms
|
execution_time_ms
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
:incident_id,
|
CAST(:incident_id AS varchar(30)),
|
||||||
:playbook_id,
|
CAST(:playbook_id AS varchar(36)),
|
||||||
:playbook_name,
|
CAST(:playbook_name AS varchar(200)),
|
||||||
:success,
|
:success,
|
||||||
CAST(:executed_steps AS jsonb),
|
CAST(:executed_steps AS jsonb),
|
||||||
:error_message,
|
:error_message,
|
||||||
:triggered_by,
|
CAST(:triggered_by AS varchar(50)),
|
||||||
:similarity_score,
|
:similarity_score,
|
||||||
:risk_level,
|
CAST(:risk_level AS varchar(20)),
|
||||||
:execution_time_ms
|
:execution_time_ms
|
||||||
WHERE NOT EXISTS (
|
WHERE NOT EXISTS (
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM auto_repair_executions existing
|
FROM auto_repair_executions existing
|
||||||
WHERE existing.incident_id = :incident_id
|
WHERE existing.incident_id = CAST(:incident_id AS varchar(30))
|
||||||
AND existing.triggered_by = :triggered_by
|
AND existing.triggered_by = CAST(:triggered_by AS varchar(50))
|
||||||
AND existing.executed_steps::text LIKE :apply_op_id_needle
|
AND existing.executed_steps::text LIKE CAST(:apply_op_id_needle AS text)
|
||||||
)
|
)
|
||||||
RETURNING id
|
RETURNING id
|
||||||
"""),
|
"""),
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from src.services.awooop_ansible_check_mode_service import (
|
|||||||
_automation_operation_log_incident_id,
|
_automation_operation_log_incident_id,
|
||||||
_build_auto_repair_execution_receipt,
|
_build_auto_repair_execution_receipt,
|
||||||
_claim_from_apply_operation_row,
|
_claim_from_apply_operation_row,
|
||||||
|
_record_auto_repair_execution_receipt,
|
||||||
build_ansible_apply_command,
|
build_ansible_apply_command,
|
||||||
build_ansible_check_mode_claim_input,
|
build_ansible_check_mode_claim_input,
|
||||||
build_ansible_check_mode_command,
|
build_ansible_check_mode_command,
|
||||||
@@ -1519,6 +1520,15 @@ def test_ansible_apply_receipt_backfill_queries_existing_apply_rows() -> None:
|
|||||||
assert "executed_steps::text LIKE" in source
|
assert "executed_steps::text LIKE" in source
|
||||||
|
|
||||||
|
|
||||||
|
def test_ansible_auto_repair_receipt_insert_casts_asyncpg_parameters() -> None:
|
||||||
|
source = inspect.getsource(_record_auto_repair_execution_receipt)
|
||||||
|
|
||||||
|
assert "CAST(:incident_id AS varchar(30))" in source
|
||||||
|
assert "CAST(:playbook_id AS varchar(36))" in source
|
||||||
|
assert "CAST(:triggered_by AS varchar(50))" in source
|
||||||
|
assert "CAST(:apply_op_id_needle AS text)" in source
|
||||||
|
|
||||||
|
|
||||||
def test_ansible_claim_query_limits_recent_candidate_backlog() -> None:
|
def test_ansible_claim_query_limits_recent_candidate_backlog() -> None:
|
||||||
source = inspect.getsource(claim_pending_check_modes)
|
source = inspect.getsource(claim_pending_check_modes)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user