Skip to content

Commit

Permalink
fix: scopes validation logs (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Dec 13, 2023
1 parent 4c7af79 commit 567d46d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions keep/api/routes/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def delete_provider(
def validate_scopes(
provider: BaseProvider, validate_mandatory=True
) -> dict[str, bool | str]:
logger.info("Validating provider scopes")
validated_scopes = provider.validate_scopes()
if validate_mandatory:
mandatory_scopes_validated = True
Expand All @@ -316,10 +317,17 @@ def validate_scopes(
break
# Otherwise we fail the installation
if not mandatory_scopes_validated:
logger.warning(
"Failed to validate mandatory provider scopes",
extra={"validated_scopes": validated_scopes},
)
raise HTTPException(
status_code=412,
detail=validated_scopes,
)
logger.info(
"Validated provider scopes", extra={"validated_scopes": validated_scopes}
)
return validated_scopes


Expand Down
2 changes: 1 addition & 1 deletion keep/providers/grafana_provider/grafana_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def validate_scopes(self) -> dict[str, bool | str]:
f"{self.authentication_config.host}/api/access-control/user/permissions"
)
try:
response = requests.get(permissions_api, headers=headers).json()
response = requests.get(permissions_api, headers=headers, timeout=5).json()
except requests.exceptions.ConnectionError:
validated_scopes = {
scope.name: "Failed to connect to Grafana. Please check your host."
Expand Down

1 comment on commit 567d46d

@vercel
Copy link

@vercel vercel bot commented on 567d46d Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

keep – ./

keep-git-main-keephq.vercel.app
keep-eight.vercel.app
platform.keephq.dev
keep-keephq.vercel.app

Please sign in to comment.