Skip to content

fix(memgw): cancel timed-out MCP calls + strict loopback host parsing — Codex PR #30 review - #31

Merged
dizhaky merged 1 commit into
mainfrom
automation/codex-review-followups-20260626
Jun 26, 2026
Merged

fix(memgw): cancel timed-out MCP calls + strict loopback host parsing — Codex PR #30 review#31
dizhaky merged 1 commit into
mainfrom
automation/codex-review-followups-20260626

Conversation

@dizhaky

@dizhaky dizhaky commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Two chatgpt-codex-connector[bot] review comments on PR #30 that still applied to current main (the other 13 were already addressed in the merged PR):

  1. client.py chore(deps): bump the npm_and_yarn group across 2 directories with 1 update #13 — Cancel timed-out MCP calls: _run_sync now cancels the concurrent.futures.Future on timeout before re-raising, so a stalled MCP endpoint doesn't leave a pending HTTP session running on the shared background loop after the caller has given up / opened the breaker.
  2. init.py chore(deps): bump esbuild and vite in /web #15 — Parse the host before allowing keyless local mode: is_available() now urlparse's the URL and requires an exact loopback host (localhost/127.0.0.1/::1) instead of a substring match, so a URL like https://localhost@example.com/mcp (host=example.com) is no longer trusted as local keyless mode.

Regression tests: test_memgw_client_timeout.py (cancel-on-timeout fails against pre-fix client) + TestKeylessLocalModeHostParsing (3/4 fail pre-fix). Full memgw suite: 184 passed; ruff clean.

Deferred (already fixed in merged PR #30): MCP dep import check, MCP dep pin, loop lock, isError handling, stale-prefetch generation, sync/delegation thread tracking + shutdown join, session-switch prefetch invalidation, no join on turn path, default provider unset.
Deferred (complex, needs interface change): #3/#4 per-turn user_id refresh for shared gateway sessions (sync_turn/prefetch only receive session_id, not user_id); #1 in-tree placement is an architectural call (AGENTS.md says existing in-tree providers stay).

🤖 Generated by the auto-fix-codex-pr-review-recommendations automation. Not auto-merged.

… — Codex PR #30 review

Two chatgpt-codex-connector[bot] review comments on PR #30 that still applied
to current main (the other 13 were already addressed in the merged PR):

1. client.py #13 — Cancel timed-out MCP calls: _run_sync now cancels the
   concurrent.futures.Future on timeout before re-raising, so a stalled MCP
   endpoint doesn't leave a pending HTTP session running on the shared
   background loop after the caller has given up / opened the breaker.
2. __init__.py #15 — Parse the host before allowing keyless local mode:
   is_available() now urlparse's the URL and requires an exact loopback host
   (localhost/127.0.0.1/::1) instead of a substring match, so a URL like
   'https://localhost@example.com/mcp' (host=example.com) is no longer trusted
   as local keyless mode.

Adds regression tests: test_memgw_client_timeout.py (cancel-on-timeout fails
against pre-fix client) + TestKeylessLocalModeHostParsing (3/4 fail pre-fix).

Deferred (already fixed in merged PR #30): MCP dep import check, MCP dep pin,
loop lock, isError handling, stale-prefetch generation, sync/delegation thread
tracking + shutdown join, session-switch prefetch invalidation, no join on
turn path, default provider unset.
Deferred (complex, needs interface change): #3/#4 per-turn user_id refresh for
shared gateway sessions — sync_turn/prefetch only receive session_id, not
user_id, so threading identity through requires a MemoryProvider interface
change; #1 in-tree placement is an architectural call (AGENTS.md says existing
in-tree providers stay).
@github-actions

Copy link
Copy Markdown

🔎 Lint report: automation/codex-review-followups-20260626 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8649 on HEAD, 8648 on base (🆕 +1)

🆕 New issues (1):

Rule Count
unresolved-import 1
First entries
tests/plugins/memory/test_memgw_client_timeout.py:11: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`

✅ Fixed issues: none

Unchanged: 4569 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@dizhaky
dizhaky marked this pull request as ready for review June 26, 2026 14:18
@dizhaky
dizhaky merged commit a10711c into main Jun 26, 2026
28 checks passed
@dizhaky
dizhaky deleted the automation/codex-review-followups-20260626 branch June 26, 2026 14:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3debe63c97

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# (Codex PR #30 review). Parse the URL and require an exact loopback host.
from urllib.parse import urlparse

host = (urlparse(url).hostname or '').lower()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle malformed memgw URLs as unavailable

When memgw runs keyless and the configured MEMGW_API_URL/memgw.json URL is malformed, such as a typoed IPv6 URL (http://[::1:8081/mcp) or an invalid NFKC hostname, accessing .hostname raises ValueError. Some status/setup paths call p.is_available() directly, so a bad config can abort the command instead of marking memgw unavailable; catch parse errors here and return False.

Useful? React with 👍 / 👎.

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