Skip to content

logSearch reports "No matches found" for a container that does not exist #142

Closed

Description

@TMHSDigital

Summary

When service names a container that does not exist, homelab_logSearch returns a successful "No matches found" instead of an error.

Where

  • mcp-server/src/tools/logSearch.ts:53, :59

Details

The single-service command is docker logs ... <service> 2>&1 | grep -i -e "$pat" | tail -N. The pipeline's exit status is that of tail (always 0). Docker's "No such container" message goes into grep through 2>&1 and is filtered out, so the handler sees empty output and reports no matches.

Impact

A typo in the container name, or a removed container, looks like "no errors in the logs", which is the wrong answer during an investigation. If the pattern matches the daemon message (the investigate-container prompt searches for error), the daemon error is returned as if it were a log line.

Steps to reproduce

  1. Call homelab_logSearch with { "service": "grafanna", "pattern": "timeout" }
  2. Result: No matches found ... instead of an error

Suggested fix

Check that the container exists first (docker inspect -f . <name> >/dev/null 2>&1 || { echo "No such container" >&2; exit 1; }), or use set -o pipefail and keep docker's stderr out of grep.

Acceptance criteria

  • Unknown container returns an error naming the container
  • Handler test covers the missing-container case

Getting started

  • Relevant files: mcp-server/src/tools/logSearch.ts
  • How to run tests: cd mcp-server && npm install && npm test (and npm run typecheck); structure tests: pip install -r requirements-test.txt && pytest tests/ -v
  • Conventions: see CLAUDE.md and CONTRIBUTING.md

Filed by repo-audit/full-audit at 636fefb. Severity: medium. Effort: S. audit-key: bug|mcp-server/src/tools/logSearch.ts|cmd

Activity

  1. added
    bug
    good first issue
    severity: medium
    on Nov 18, 2026
  2. TMHSDigital commented on Nov 19, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in b1c6c07: with service set, logSearch first runs docker inspect --type container and fails with 'No such container: ' instead of returning 'No matches found'. Verified with a handler test for the missing-container case; build, typecheck, Vitest and structure tests pass.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions