Skip to content

Fix misleading "Failed to auto-start" warnings on component creation#118

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-log-messages-drasi-server
Draft

Fix misleading "Failed to auto-start" warnings on component creation#118
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-log-messages-drasi-server

Conversation

Copilot AI commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Creating a reaction (or source) with autoStart: true logged a spurious WARN ... Failed to auto-start ... is already running, even though the component started fine. A genuine start failure was also logged at WARN rather than ERROR.

Root cause

DrasiLib::add_{reaction,source}_with_metadata already auto-starts the component when the server is running. The create/upsert handlers then called start_* again unconditionally — the second start hit an already-running component, producing the misleading warning (plus extra drasi-lib state-transition warnings for some component types).

Changes

  • Guard the redundant start — handlers now only call start_* when the component is still Stopped (i.e. add did not auto-start it, e.g. server not yet running).
  • Raise log level — genuine auto-start failures now log at ERROR instead of WARN.
  • Applied consistently across reaction and source create + upsert handlers.
if auto_start {
    // add_*_with_metadata already auto-starts when the server is running;
    // only start here if it's still Stopped, and treat real failures as errors.
    if matches!(
        core.get_reaction_status(&reaction_id).await,
        Ok(ComponentStatus::Stopped)
    ) {
        if let Err(e) = core.start_reaction(&reaction_id).await {
            log::error!("Failed to auto-start reaction '{reaction_id}': {e}");
        }
    }
}

Tests

  • Added test_create_reaction_auto_start_via_api: POSTs a reaction with autoStart: true and asserts it reaches Running. Logs confirm the component is now started exactly once.

Copilot AI requested review from Copilot and removed request for Copilot June 4, 2026 02:55
Copilot AI linked an issue Jun 4, 2026 that may be closed by this pull request
Copilot AI requested review from Copilot and removed request for Copilot June 4, 2026 03:30
Copilot AI changed the title [WIP] Fix incorrect log messages starting up Drasi Server Fix misleading "Failed to auto-start" warnings on component creation Jun 4, 2026
Copilot AI requested a review from agentofreality June 4, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect log messages starting up Drasi Server

2 participants