Skip to content

Add FlexMeasures-Version and API-Version response headers#2021

Open
Copilot wants to merge 4 commits intomainfrom
copilot/add-custom-headers-api-versions
Open

Add FlexMeasures-Version and API-Version response headers#2021
Copilot wants to merge 4 commits intomainfrom
copilot/add-custom-headers-api-versions

Conversation

Copy link
Contributor

Copilot AI commented Mar 13, 2026

Clients have no programmatic way to identify the server version or API version from HTTP responses alone.

Changes

  • flexmeasures/api/__init__.py: Registers an app.after_request hook in register_at() that injects version headers based on request path prefix:

    • FlexMeasures-Version: <version> on all responses under /api/
    • API-Version: v3_0 additionally on all responses under /api/v3_0
  • flexmeasures/api/tests/test_headers.py: New test file covering header presence on v3_0 and non-v3_0 API endpoints, and absence of API-Version on non-v3_0 endpoints.

  • documentation/api/introduction.rst: Added description of the new response headers at the end of the "Main endpoint and API versions" section; removed an outdated note from that section.

  • documentation/api/change_log.rst: Added entries under v3.0-30 documenting the new FlexMeasures-Version and API-Version response headers.

Example

GET /api/v3_0/health/ready HTTP/1.1

HTTP/1.1 200 OK
FlexMeasures-Version: 0.32.0
API-Version: v3_0
...

GET /api/ops/ping HTTP/1.1

HTTP/1.1 200 OK
FlexMeasures-Version: 0.32.0
...
Original prompt

This section details on the original issue you should resolve

<issue_title>Use custom headers to communicate server/API versions</issue_title>
<issue_description>- All API responses should include the FlexMeasures-Version: 0.32.0 header, updated with the current server version.

Comments on the Issue (you are @copilot in this section)


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

@read-the-docs-community
Copy link

read-the-docs-community bot commented Mar 13, 2026

Documentation build overview

📚 flexmeasures | 🛠️ Build #31793606 | 📁 Comparing 391e59f against latest (c6bb60f)


🔍 Preview build

Show files changed (4 files in total): 📝 4 modified | ➕ 0 added | ➖ 0 deleted
File Status
changelog.html 📝 modified
api/change_log.html 📝 modified
api/introduction.html 📝 modified
api/v3_0.html 📝 modified

@nhoening
Copy link
Contributor

I suggest using the dedicated Header field: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Server

So maybe: Server: FlexMeasures/0.31.2

Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot AI changed the title [WIP] Add custom headers to communicate server and API versions Add FlexMeasures-Version and API-Version response headers Mar 13, 2026
Copilot AI requested a review from Flix6x March 13, 2026 12:17
@Flix6x
Copy link
Contributor

Flix6x commented Mar 13, 2026

I suggest using the dedicated Header field: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Server

So maybe: Server: FlexMeasures/0.31.2

  • From what I've read the Server header is typically used for things like:
    • Server: Apache/2.4.1 (Unix)
    • Server: nginx/1.24.0
    • Server: gunicorn
  • It is considered a security risk and actually recommended to mask the version
  • I believe having Flask set this header is pointless, as the reverse proxy server would override it.

Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x marked this pull request as ready for review March 13, 2026 13:02
@nhoening
Copy link
Contributor

I believe having Flask set this header is pointless, as the reverse proxy server would override it.

That might be true. FlexMeasures can be considered to not be the server.

Another thing I'd like in this PR is to mention this setting in the documentation which talks about the API, maybe below the Authentication section.

@Flix6x
Copy link
Contributor

Flix6x commented Mar 13, 2026

@copilot a few follow-ups:

  • Mention the new headers at the end of the Main endpoint and API versions section
  • Remove the existing note in that section, as it's outdated.
  • Add an entry to documentation/api/change_log.rst under v3.0-30, mentioning the exact headers introduced.
  • The /api/v3_0 endpoint currently fails on a 500 status error with 'NoneType' object is not iterable". Write a test for this endpoint, and fix the underlying issue, in a separate PR.

@Flix6x Flix6x added this to the 0.32.0 milestone Mar 13, 2026
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 13, 2026

I believe having Flask set this header is pointless, as the reverse proxy server would override it.

That might be true. FlexMeasures can be considered to not be the server.
...

Done in commit 391e59f — added documentation about the new version headers at the end of the "Main endpoint and API versions" section.

@copilot a few follow-ups:

Done in commit 391e59f:

  • Mentioned the new headers at the end of the "Main endpoint and API versions" section in documentation/api/introduction.rst
  • Removed the outdated note from that section
  • Added entries to documentation/api/change_log.rst under v3.0-30 for both headers

The /api/v3_0 500 error fix will be addressed in a separate PR as requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use custom headers to communicate server/API versions

3 participants