Frun1na opened a new pull request, #4627: URL: https://github.com/apache/rocketmq-dashboard/pull/4627
### Which Issue(s) This PR Fixes ### Brief Description `rmqctl --timeout 0s` (or any negative duration) currently fails every command immediately with `context deadline exceeded`: ``` $ rmqctl --server http://localhost:8080 --instance-id instance-dev --timeout 0s topic list Error: Post "http://localhost:8080/api/mcp/tools/call": context deadline exceeded ``` The cause is `Client.request` in `rmqctl/internal/studio/client.go`, which unconditionally passes `target.Timeout` to `context.WithTimeout`. A non-positive duration expires the context before the request is even sent. The `--timeout` flag accepts any `time.Duration`, so nothing stops a user from typing `0s` expecting "no timeout" (the common convention) and instead hitting this. This PR treats a non-positive timeout as "no client-side timeout", mirroring the existing handling in `rmqctl/internal/studio/mcp_message.go` (`if session.timeout > 0`). Positive timeouts behave exactly as before. ### How Did You Test This Change? ``` $ cd rmqctl $ go test ./internal/studio/ -run 'TestCallTool' -v === RUN TestCallTool --- PASS: TestCallTool (0.00s) === RUN TestCallToolIgnoresNonPositiveTimeout === RUN TestCallToolIgnoresNonPositiveTimeout/zero --- PASS: TestCallToolIgnoresNonPositiveTimeout/zero (0.00s) === RUN TestCallToolIgnoresNonPositiveTimeout/negative --- PASS: TestCallToolIgnoresNonPositiveTimeout/negative (0.00s) === RUN TestCallToolKeepsCatalogControlsInArguments --- PASS: TestCallToolKeepsCatalogControlsInArguments (0.00s) PASS ok github.com/apache/rocketmq-dashboard/rmqctl/internal/studio 0.016s ``` The new test `TestCallToolIgnoresNonPositiveTimeout` covers both `0` and `-time.Second`; before the fix both subtests fail with `context deadline exceeded`, after the fix they pass. ``` $ go test ./... $ go test -race ./cmd/ ./internal/studio/ $ gofmt -l . $ go vet ./... ``` All pass; `gofmt -l` prints nothing. ### Checklist - [x] Follows the project style / conventions of the surrounding code - [x] New/changed behavior is covered by tests - [x] `go test ./...`, `go vet`, `gofmt` all pass locally -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
