Skip to content

fix(httpapi): flaky activation scope assertion - #1329

Merged
Dumbris merged 2 commits into
smart-mcp-proxy:mainfrom
lux-liang:fix/1206-flaky-activation-assertion
Sep 21, 2026
Merged

Dumbris merged 2 commits into
smart-mcp-proxy:mainfrom
lux-liang:fix/1206-flaky-activation-assertion

Conversation

@lux-liang

Copy link
Copy Markdown
Contributor

Pull Request

Description

Fixes #1206.

The scoped /api/v1/status test searched the entire JSON response for the bare
digits 4711. A Unix timestamp containing those digits could therefore fail
the test even though the deployment-wide counter was correctly withheld.

This change matches a complete JSON numeric value instead. It still catches the
count if a projection exposes it under a renamed key, while ignoring the same
digits embedded in a larger timestamp.

Testing

  • I have tested these changes locally
  • I have added/updated tests that prove my fix is effective or my feature works
  • All existing tests pass

Passing checks:

  • go test ./internal/httpapi -run '^TestGetStatus_ActivationBlockIsOperatorOnly$' -count=50
  • go test -race ./internal/httpapi -run '^TestGetStatus_ActivationBlockIsOperatorOnly$' -count=20
  • go test ./internal/httpapi -count=1
  • go vet ./internal/httpapi
  • golangci-lint run --new-from-rev=HEAD ./internal/httpapi/...

go test ./internal/... was also attempted. The target package passed, while
unrelated environment-sensitive tests failed because the test host runs as
root (read-only-directory assertions), uses /var/log/mcpproxy, and did not
have the prebuilt E2E binary expected by internal/server.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Replace the regex-based NotRegexp check with two plain NotContains
calls for the same boundary condition, matching every other
assertion in this file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Dumbris

Dumbris commented Sep 21, 2026

Copy link
Copy Markdown
Member

Thanks for the fix, @lux-liang! Nice catch on the timestamp false-positive. I pushed a small follow-up commit simplifying the leak-check assertion to two plain assert.NotContains calls (matching the rest of the file's idiom) instead of the regex — no behavior change, just consistency.

@Dumbris Dumbris changed the title Fix flaky activation scope assertion fix(httpapi): flaky activation scope assertion Sep 21, 2026
@Dumbris
Dumbris merged commit 1e29fe0 into smart-mcp-proxy:main Sep 21, 2026
40 of 41 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.

Flaky: TestGetStatus_ActivationBlockIsOperatorOnly fails whenever the unix timestamp contains "4711"

3 participants