Skip to content

mcpx(adapter): a negative timeout passes Validate and makes every tool call fail instantly — parseDuration accepts -5s, Run's WithTimeout is born expired and reports 'did not finish within -5s' #1758

Closed

Description

@dezren39

Problem

An mcpx adapter spec (or one of its tools) with a negative timeout — e.g. "timeout": "-5s" — passes Spec.Validate() cleanly, then makes every call of that tool fail instantly with a misleading timeout error, even for a command that finishes in milliseconds.

Evidence (main 5ac81cae, pkgs/mcpx/internal/adapter/adapter.go, blob fbd12f85)

  • adapter.go:148-158 — parseDuration returns whatever time.ParseDuration accepts; negative durations parse without error.
  • adapter.go:105 and adapter.go:137-139 — Spec.Validate() checks the server and per-tool timeouts only for a parse error, so "-5s" and "-1ns" validate fine. Validation is documented as catching "the kind [of failure] that would otherwise surface as a confusing command line" (adapter.go:94-97) — this is exactly that kind, and it slips through.
  • adapter.go:230-234 — Run selects the timeout: timeout, _ := parseDuration(spec.Timeout, 0); the server fallback applies only when timeout == 0, so a negative tool timeout is used as-is. context.WithTimeout(ctx, -5s) returns a context that is already expired.
  • adapter.go:237,256-260 — exec.CommandContext with the born-expired context fails immediately, cctx.Err() != nil, and the caller is told "<server>.<tool> did not finish within -5s" — the command never really ran, and the message blames its speed.

Verification (this run)

Laptop probe ~/git/fleet/probe-2026-10-28-laneA-adapter-negtimeout/ (Go 1.26.8, on the laptop per the no-sandbox-builds rule): parseDuration copied verbatim from the blob above, plus a mirror of Run's timeout selection / WithTimeout / CommandContext flow running echo hi:

  • Control: timeout=5s → out="hi", no error.
  • Case: timeout=-5s → Validate-equivalent check passes (err=nil); the run fails instantly with did not finish within -5s and empty output.
  • Case: tool timeout=-1ns with server timeout=5s → still fails instantly; the non-zero negative value suppresses the server fallback.

Why it matters

Adapter specs are user/declaration files. A single typo (-5s, or a templated value that goes negative) produces a spec that every static check accepts and that then fails 100% of calls with an error message pointing at the tool's execution time rather than at the config — the hardest kind of misconfiguration to diagnose from the caller's side.

Acceptance criteria

  • Spec.Validate() rejects a negative timeout at both the server level and the per-tool level, naming the offending value (and a negative value can no longer reach Run).
  • The pinned behaviour for timeout: "0s" / "0" is stated in a comment or doc at parseDuration/Run: today 0 at tool level silently means "use the server timeout"; whatever is decided (keep, or reject), a test pins it.
  • Regression tests in internal/adapter: negative server timeout refused, negative tool timeout refused, positive timeout still runs a trivial command to completion.
  • Existing internal/adapter tests still pass (laptop or CI).

Scope / triage notes

  • Fix site is pkgs/mcpx/internal/adapter only. Sibling duration parsers exist elsewhere (e.g. internal/settings KindDuration, internal/execsvc); whether they share the rule is a triage question — do not silently widen this issue to them.
  • Not self-solved by the filing lane: the 0-timeout semantics above are a small contract decision for triage, and the fix should land through the queue with the adapter tests.

Activity

  1. developing-today commented on Oct 28, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Oct 28, 2026
  3. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator-code-a (new-issue-creator job, lane A)
    • Session / ID: cron new-issue-creator-code-a run, 2026-10-28 12:35 CDT
    • Found via: filed this run
    • Task: Filed this issue after verifying it this run — adapter parseDuration accepts negative durations, Spec.Validate() passes them, and Run's born-expired WithTimeout context fails every call with a misleading timeout message. Evidence and probe results are in the issue body.
    • Expectation: effort/s — triage pins the negative-timeout refusal (and the 0s semantics), then a small fix in internal/adapter with regression tests.
    • Links: queue packet hidden_files/queue-packets/packet-1758.json (goal workspace); probe ~/git/fleet/probe-2026-10-28-laneA-adapter-negtimeout/ (laptop)
  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Oct 28, 2026
  5. 34 remaining items

  6. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    Agent note — parked (CI pending)

  7. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 28, 2026
  8. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  9. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions