From b43448fc538885a9feb552ba06d7f56ba9ccf6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20L=C3=B3pez=20Dato?= Date: Wed, 11 Dec 2024 14:53:11 -0300 Subject: [PATCH 1/2] Respond to /api/v1/environment-document with 400 --- src/edge_proxy/server.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/edge_proxy/server.py b/src/edge_proxy/server.py index 1413417..5c44375 100644 --- a/src/edge_proxy/server.py +++ b/src/edge_proxy/server.py @@ -1,3 +1,4 @@ +import http from datetime import datetime, timedelta import httpx @@ -85,13 +86,26 @@ async def flags(feature: str = None, x_environment_key: str = Header(None)): @app.post("/api/v1/identities/", response_class=ORJSONResponse) async def identity( - input_data: IdentityWithTraits, - x_environment_key: str = Header(None), + input_data: IdentityWithTraits, + x_environment_key: str = Header(None), ): data = environment_service.get_identity_response_data(input_data, x_environment_key) return ORJSONResponse(data) +@app.get("/api/v1/environment-document/") +def environment_document(): + return ORJSONResponse( + status_code=http.HTTPStatus.BAD_REQUEST, + content={ + "message": "The Edge Proxy does not serve environment documents and cannot be consumed using local " + "evaluation. Make sure your Flagsmith client application is consuming the Edge Proxy using " + "remote evaluation, i.e. using a client-side environment key and with local evaluation " + "disabled. See https://docs.flagsmith.com/clients/" + } + ) + + @app.on_event("startup") @repeat_every( seconds=settings.api_poll_frequency_seconds, From 534e004591097c25d8867350ff7f306e552381c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:56:15 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/edge_proxy/server.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/edge_proxy/server.py b/src/edge_proxy/server.py index 5c44375..4fab635 100644 --- a/src/edge_proxy/server.py +++ b/src/edge_proxy/server.py @@ -86,8 +86,8 @@ async def flags(feature: str = None, x_environment_key: str = Header(None)): @app.post("/api/v1/identities/", response_class=ORJSONResponse) async def identity( - input_data: IdentityWithTraits, - x_environment_key: str = Header(None), + input_data: IdentityWithTraits, + x_environment_key: str = Header(None), ): data = environment_service.get_identity_response_data(input_data, x_environment_key) return ORJSONResponse(data) @@ -99,10 +99,10 @@ def environment_document(): status_code=http.HTTPStatus.BAD_REQUEST, content={ "message": "The Edge Proxy does not serve environment documents and cannot be consumed using local " - "evaluation. Make sure your Flagsmith client application is consuming the Edge Proxy using " - "remote evaluation, i.e. using a client-side environment key and with local evaluation " - "disabled. See https://docs.flagsmith.com/clients/" - } + "evaluation. Make sure your Flagsmith client application is consuming the Edge Proxy using " + "remote evaluation, i.e. using a client-side environment key and with local evaluation " + "disabled. See https://docs.flagsmith.com/clients/" + }, )