From bcfbaa401825718d2e3c5ee198fd306312be2a90 Mon Sep 17 00:00:00 2001 From: tomaioo Date: Sun, 14 Jun 2026 17:09:36 -0700 Subject: [PATCH] fix(ui): deprecated api endpoints lack clear deprecation he The deprecated SensorEntityAddressAPI endpoints in deprecated.py only log warnings and include deprecation notices in docstrings, but do not send standard HTTP deprecation headers (like Sunset or Deprecation headers) that automated clients and developers rely on to detect deprecated APIs programmatically. Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com> --- flexmeasures/api/v3_0/deprecated.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/flexmeasures/api/v3_0/deprecated.py b/flexmeasures/api/v3_0/deprecated.py index 0974abac21..936addb706 100644 --- a/flexmeasures/api/v3_0/deprecated.py +++ b/flexmeasures/api/v3_0/deprecated.py @@ -3,6 +3,14 @@ from flask_security import auth_required, current_user from webargs.flaskparser import use_args + +def _deprecation_headers(): + return { + "Deprecation": "true", + "Sunset": "Sat, 01 Jan 2025 00:00:00 GMT", + "Link": '; rel="successor-version"', + } + from flexmeasures.api.common.schemas.sensor_data import ( GetSensorDataSchema, GetSensorDataSchemaEntityAddress, @@ -53,7 +61,7 @@ def get_data_deprecated(self, sensor_data_description: dict): sensor_data_description ) d, s = request_processed() - return dict(**response, **d), s + return dict(**response, **d), s, _deprecation_headers() @route("/data", methods=["POST"]) @use_args( @@ -81,4 +89,4 @@ def post_data_deprecated(self, data: dict): f"User {current_user} called the deprecated endpoint /sensors/data for sensor {sensor_id}. Should start using /sensors/{sensor_id}/data." ) response, code = save_and_enqueue(bdf) - return response, code + return response, code, _deprecation_headers()