Skip to content

Commit

Permalink
fix issue not checking if data is None
Browse files Browse the repository at this point in the history
  • Loading branch information
omer9564 committed Apr 11, 2024
1 parent 8795fb9 commit a9cf753
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions horizon/enforcer/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ async def notify_seen_sdk(
return x_permit_sdk_language


async def post_to_opa(request: Request, path: str, data: dict):
async def post_to_opa(request: Request, path: str, data: dict | None):
headers = transform_headers(request)
url = f"{opal_client_config.POLICY_STORE_URL}/v1/data/{path}"
exc = None
Expand Down Expand Up @@ -252,8 +252,8 @@ async def post_to_opa(request: Request, path: str, data: dict):
raise exc


def _set_use_debugger(data) -> None:
if data.get("input") is not None:
def _set_use_debugger(data: dict | None) -> None:
if data is not None and data.get("input") is not None:
if "use_debugger" not in data["input"]:
if sidecar_config.IS_DEBUG_MODE is not None:
data["input"]["use_debugger"] = sidecar_config.IS_DEBUG_MODE
Expand Down Expand Up @@ -495,8 +495,8 @@ async def is_allowed(
raise HTTPException(
status_code=status.HTTP_421_MISDIRECTED_REQUEST,
detail="Mismatch between client version and PDP version,"
" required v2 request body, got v1. "
"hint: try to update your client version to v2",
" required v2 request body, got v1. "
"hint: try to update your client version to v2",
)
query = cast(AuthorizationQuery, query)

Expand Down Expand Up @@ -536,7 +536,7 @@ async def is_allowed_kong(request: Request, query: KongAuthorizationQuery):
raise HTTPException(
status.HTTP_503_SERVICE_UNAVAILABLE,
detail="Kong integration is disabled. "
"Please set the PDP_KONG_INTEGRATION variable to true to enable it.",
"Please set the PDP_KONG_INTEGRATION variable to true to enable it.",
)

await PersistentStateHandler.get_instance().seen_sdk("kong")
Expand Down

0 comments on commit a9cf753

Please sign in to comment.