Skip to content

fix(health): skip immediate health check on import when health is disabled#689

Merged
javi11 merged 1 commit into
mainfrom
session/charming-euclid-f38a27
Jun 15, 2026
Merged

fix(health): skip immediate health check on import when health is disabled#689
javi11 merged 1 commit into
mainfrom
session/charming-euclid-f38a27

Conversation

@javi11

@javi11 javi11 commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Problem

When health checking is disabled in config (health.enabled: false), successfully imported items were still queued for an immediate health check. Records were written to the file_health table as pending and stayed there forever — the health worker correctly refuses to process them (internal/health/worker.go:128), but they should never have been queued in the first place.

This affected the default install, since health checking is disabled by default (internal/config/manager.go:1439).

Root cause

Coordinator.ScheduleHealthCheck is called unconditionally after every successful import (coordinator.go:133). The scheduler only guarded on c.healthRepo == nil (a dependency check) and never checked cfg.GetHealthEnabled(), so it queued records and resolved pending repairs regardless of the config flag.

Change

  • health_scheduler.go: Added an early-return guard on c.configGetter().GetHealthEnabled() right after the healthRepo == nil check — before any path expansion, record building, batch upsert, or pending-repair resolution. Skipping repair resolution when disabled is intentional and consistent: both are health-subsystem concerns.
  • health_scheduler_test.go: Added TestScheduleHealthCheck_DisabledQueuesNothing (asserts no records queued and stale repairs untouched when disabled). Set Health.Enabled = true in the shared setupSchedulerTest helper so the existing scheduling tests run with health on — their actual intent. They previously passed only because of the bug, since DefaultConfig() disables health.

Verification

  • go test ./internal/importer/postprocessor/... -run HealthCheck -race — pass
  • go build ./... — clean
  • go test ./internal/importer/... — all green

Reviewer notes

This fixes the import-time trigger specifically. A separate library-sync path can also register health records; that was out of scope for this report ("imported items sent to immediate health check") but may be worth a follow-up check on whether it's also gated on health.enabled.

…abled

ScheduleHealthCheck only guarded on a nil healthRepo, never on the
health.enabled config flag. Since health checking is disabled by default,
every successful import queued file_health rows as pending (and resolved
pending repairs) for a feature the user had turned off; the worker then
refused to process them, leaving orphaned rows forever.

Add an early-return guard on GetHealthEnabled() before any path expansion,
queuing, or repair resolution. Enable health in the shared scheduler test
helper (its intent is to exercise scheduling) and add a test asserting the
disabled path queues nothing and leaves stale repairs untouched.
@javi11 javi11 merged commit 0b202e0 into main Jun 15, 2026
2 checks passed
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