Skip to content

Log error when host_script_result record is not found#40009

Merged
nulmete merged 2 commits intomainfrom
nulmete/orphan-host-script-results-404
Feb 18, 2026
Merged

Log error when host_script_result record is not found#40009
nulmete merged 2 commits intomainfrom
nulmete/orphan-host-script-results-404

Conversation

@nulmete
Copy link
Copy Markdown
Member

@nulmete nulmete commented Feb 18, 2026

Related issue: Resolves #33090

All the calls to getHostScriptExecutionResultDB within GetHostLockWipeStatus now log an error with the hostID and execID if no rows are found. (As agreed with @lucasmrod instead of modifying the DB as I proposed in the issue, at least for now).

Testing

  • QA'd all new/changed functionality manually

  • Set the unlock_reference to a dummy value for a host_mdm_action => reproduced 404.

  • Restarted the server with the fix => host details page loaded.

hsr_1.mov
hsr_2.mov

@nulmete nulmete requested a review from a team as a code owner February 18, 2026 13:25
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.28%. Comparing base (6ba40a3) to head (8a46abf).
⚠️ Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
server/datastore/mysql/scripts.go 0.00% 3 Missing and 6 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #40009   +/-   ##
=======================================
  Coverage   66.28%   66.28%           
=======================================
  Files        2441     2441           
  Lines      195640   195646    +6     
  Branches     8542     8542           
=======================================
+ Hits       129682   129693   +11     
+ Misses      54208    54205    -3     
+ Partials    11750    11748    -2     
Flag Coverage Δ
backend 68.08% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nulmete nulmete merged commit 5192135 into main Feb 18, 2026
45 checks passed
@nulmete nulmete deleted the nulmete/orphan-host-script-results-404 branch February 18, 2026 17:07
nulmete added a commit that referenced this pull request Mar 9, 2026
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #36682 

- Added similar "not found" handling than the one we have when calling
`getHostScriptExecutionResultDB` within the `GetHostLockWipeStatus`
function for consistency => now return a 404 instead of a 500 when no
rows are returned.
- Applied similar changes to
#33090 (PR:
#40009) => logging an error instead
of returning a 404, so that the Host details page does not crash.

The actual fix would be to remove the `host_mdm_actions` record that
contains the orphan `lock_ref` mentioned in the issue.
I'm not sure what the root cause is, but I think setting up some
monitoring on the logs I added should help determining that.

# Checklist for submitter

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [x] Added/updated automated tests

- [ ] QA'd all new/changed functionality manually
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.

Host record exists in some places but not others

2 participants