Skip to content

Commit

Permalink
Fix issue with opa engine to handle exceptions as bubbled exceptions …
Browse files Browse the repository at this point in the history
…disrupt rpe engine policy execution.
  • Loading branch information
neerajtickoo committed Aug 12, 2024
1 parent aaf1665 commit f38602a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions rpe/engines/opa.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ def _opa_request(self, path, method="GET", data=None):

# Perform an evaluation on a given resource
def evaluate(self, resource):
input = {
"input": resource.get(),
}

evals = self._opa_request("rpe/evaluate_v2", method="POST", data=input)

return [Evaluation(engine=self, resource=resource, **ev) for ev in evals]
try:
_input = {
"input": resource.get(),
}
evals = self._opa_request("rpe/evaluate_v2", method="POST", data=_input)
return [Evaluation(engine=self, resource=resource, **ev) for ev in evals]
except Exception as e:
print(f"Exception during OPA eval. Resource Name: {resource.name}, Project: {resource.project_id}, "
f"location: {resource.location}. Exception Message: {str(e)}")

return []

def policies(self):
"""
Expand Down

0 comments on commit f38602a

Please sign in to comment.