Skip to content

Add X-OpenPLC-Runtime-Version header to all API responses#50

Merged
thiagoralves merged 1 commit into
developmentfrom
devin/1766011526-runtime-version-header
Dec 17, 2025
Merged

Add X-OpenPLC-Runtime-Version header to all API responses#50
thiagoralves merged 1 commit into
developmentfrom
devin/1766011526-runtime-version-header

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Adds an after_request hook to the REST API blueprint that includes the X-OpenPLC-Runtime-Version header with value v4 in all API responses. This enables the OpenPLC Editor to detect which runtime version it is connecting to and show an error if there is a version mismatch between the selected target (v3 vs v4) and the actual runtime.

This is part of a coordinated change across three repositories:

  • OpenPLC_v3 - adds v3 header (PR Rtop 70 implement command logs #7)
  • openplc-runtime (this PR) - adds v4 header
  • openplc-editor - will read the header and validate version match

The diff also includes minor cleanup from pre-commit hooks: removed unused LogParser import, removed unused exception variable e, and import reordering.

Review & Testing Checklist for Human

  • Verify the header X-OpenPLC-Runtime-Version: v4 appears on API responses by running the runtime and testing with curl:
    curl -v -k https://localhost:8443/api/get-users-info 2>&1 | grep -i "x-openplc"
  • Confirm the header appears on both 200 and 404 responses (e.g., when no users exist vs when users exist)
  • Verify the pre-commit cleanup (removing unused LogParser import and unused e variable) doesn't affect any other code paths

Notes

This adds an after_request hook to the REST API blueprint that includes
the X-OpenPLC-Runtime-Version header with value 'v4' in all API responses.

This enables the OpenPLC Editor to detect which runtime version it is
connecting to and show an error if there is a version mismatch between
the selected target and the actual runtime.

Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds version detection capability to the OpenPLC v4 runtime API by injecting an X-OpenPLC-Runtime-Version: v4 header into all API responses. This allows the OpenPLC Editor to verify it's connecting to the correct runtime version and alert users about version mismatches. The change also includes automated code cleanup from pre-commit hooks, including import reordering, removal of an unused LogParser import, removal of an unused exception variable, and code formatting adjustments.

Key changes:

  • Added after_request hook to inject version header into all API responses
  • Removed unused imports and variables flagged by pre-commit tools
  • Minor formatting improvements to existing code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@thiagoralves thiagoralves merged commit 477b35a into development Dec 17, 2025
1 check passed
@thiagoralves thiagoralves deleted the devin/1766011526-runtime-version-header branch December 18, 2025 14:08
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.

2 participants