Skip to content

Hotfix/machine id header - #96

Open
mikhailm-coder wants to merge 2 commits into
mainfrom
hotfix/machine-id-header
Open

Hotfix/machine id header#96
mikhailm-coder wants to merge 2 commits into
mainfrom
hotfix/machine-id-header

Conversation

@mikhailm-coder

@mikhailm-coder mikhailm-coder commented Aug 10, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • OpenFrame requests now include a machine identifier when available.
    • Machine identifiers are read from the system and cached for reuse.
    • Added support for refreshing the machine identifier when needed.
  • Bug Fixes

    • Improved handling of missing, empty, or whitespace-only machine ID files.

mikhailm-coder and others added 2 commits July 30, 2026 17:32
…ame mode

Ports the March feature/machine-id-header work onto current main: a cached
provider reads the shared OpenFrame machine_id file written by
openframe-client, and orbit stamps it on every request alongside the
bearer token.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

# Conflicts:
#	client/orbit_client.go
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

OpenFrame mode now creates and stores an OpenFrameMachineIdProvider. The provider resolves a platform-specific file path, reads and trims the machine ID, caches it, and supports synchronized refresh. OpenFrame requests continue to use bearer authentication and now add a non-empty x-machine-id header when available.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding a machine ID header for OpenFrame requests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/machine-id-header

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/service/openframe/openframe_machine_id_provider.go`:
- Around line 41-42: Update OpenFrameMachineIdProvider.GetMachineId around the
initial read so an empty, non-configured machine ID is not permanently cached:
re-read the file when the cached value is blank, or invoke Refresh at an
appropriate lifecycle point before requests depend on x-machine-id. Preserve
normal caching for valid IDs and configured values.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d46d40e-830f-4ceb-a76c-21fc82fdb9c3

📥 Commits

Reviewing files that changed from the base of the PR and between 0b322fe and 5409376.

⛔ Files ignored due to path filters (1)
  • openframe/docs/agent-openframe-mode.md is excluded by !**/*.md
📒 Files selected for processing (2)
  • client/orbit_client.go
  • server/service/openframe/openframe_machine_id_provider.go

Comment on lines +41 to +42
p.machineId = p.readFromFile()
p.initialized = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect OrbitClient methods for an explicit refresh lifecycle.
ast-grep outline client/orbit_client.go --items all --type function,method --view expanded
rg -n -C 3 '\bmachineIdProvider\.Refresh\s*\(' client/orbit_client.go

# Locate direct refresh invocations for the provider implementation.
rg -n -C 3 '\bOpenFrameMachineIdProvider\b|\bRefresh\s*\(' --glob '*.go'

Repository: flamingo-stack/fleetmdm

Length of output: 3379


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map and inspect the provider and OrbitClient machine-ID related code.
sed -n '1,120p' server/service/openframe/openframe_machine_id_provider.go
printf '\n--- client/orbit_client.go machine-id snippets ---\n'
rg -n -C 5 'machineIdProvider|OpenFrameMachineIdProvider|GetMachineId|NewOpenFrameMachineIdProvider|x-machine-id|Machine' server/service/openframe/openframe_machine_id_provider.go client/orbit_client.go || true

printf '\n--- all Refresh calls in Go files ---\n'
rg -n -C 3 '\.Refresh\s*\(' . --glob '*.go' || true

Repository: flamingo-stack/fleetmdm

Length of output: 13584


Add a recover path for empty cached machine IDs.

OpenFrameMachineIdProvider.GetMachineId() caches "" after the first file read if the file is missing, unreadable, or contains only whitespace. No production code calls the provider’s Refresh, but existing requests omit x-machine-id when the cache is empty. Force a re-read when the first non-configured cached value is blank, or call Refresh at a lifecycle point where the file can become available before later requests depend on the header.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/service/openframe/openframe_machine_id_provider.go` around lines 41 -
42, Update OpenFrameMachineIdProvider.GetMachineId around the initial read so an
empty, non-configured machine ID is not permanently cached: re-read the file
when the cached value is blank, or invoke Refresh at an appropriate lifecycle
point before requests depend on x-machine-id. Preserve normal caching for valid
IDs and configured values.

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.

1 participant