[Bug]: CLI MCP generation reports success after HTTP errors and overwrites an existing configuration

Đang mở
#4,344 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
backend-api-design, cli

Hướng nghiên cứu

Start with cli/src/internal/mcp/generator.go, especially postJSONRPCWithSession, initializeMCPServer, and the output-writing path identified in the issue. Trace how HTTP errors and JSON-RPC results flow through discovery, and check how bodyless 202 notification responses are handled. Done means failed initialization or discovery returns a nonzero exit and preserves the existing file, while successful discovery still generates the configuration.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Aspect/AI Aspect/API Aspect/Configuration. Severity/Major
Description

ap gateway mcp generate in WSO2 API Platform CLI ap v0.9.1 can exit successfully after HTTP authentication or service errors when the error body is a JSON object without a JSON-RPC error property. It treats the missing list result as an empty catalogue and overwrites an existing generated-mcp.yaml with empty lists.

This is incorrect error handling and configuration loss. It does not bypass authentication and does not grant access to protected server data.

Steps to Reproduce
  1. Download and extract the official CLI release ap/v0.9.1.

  2. Download reproduce_mcp.py (Python standard library only).

  3. Run:

    python reproduce_mcp.py --binary /absolute/path/to/ap --case json --case http_503_tools --case http_401_all
    

    On Windows use --binary "C:\tools\ap.exe" and python or py as appropriate.

Each error case writes a marker into a temporary generated-mcp.yaml before invoking the CLI, so preservation can be checked without touching a real configuration. Fixture responses:

  • http_503_tools: initialize succeeds and advertises all capabilities; tools/list responds with HTTP 503 and {"message":"Service temporarily unavailable"}. Other list methods succeed.
  • http_401_all: every POST including initialize responds with HTTP 401 and {"detail":"Unauthorized"}, representing an upstream authentication layer.
Actual result
Case CLI exit Echo tool in output Existing config preserved
json (control) 0 Yes n/a
http_503_tools 0 No No
http_401_all 0 No No

Both error cases print MCP generated successfully., report zero tools, and replace the previous configuration with tools: [], prompts: [], resources: []. In the 401 case the CLI proceeds through every discovery method even though initialization failed. No error is emitted on stderr.

Expected result

Return a nonzero exit status with the HTTP status and a useful error message. Do not write or overwrite the generated configuration after a failed initialization or any failed discovery request. A bodyless 202 notification response should remain a separate accepted case from JSON-RPC request responses.

Source evidence and suggested direction

Check HTTP status before decoding list results, validate the JSON-RPC envelope/result, and commit generated output only after the whole discovery sequence succeeds.

Environment Details
  • Product/component: WSO2 API Platform CLI, official Linux amd64 release ap/v0.9.1 (ap version v0.9.1 (built at 2026-08-07T09:04:19Z)).
  • Test runtime: Linux 6.18.57 x86_64 with glibc 2.41, Python 3.12.14.
  • Source reviewed: api-platform main at 398d50772b5605ffe0d6d8693aa7b9ce7c84032e; inspected, not compiled or executed.
  • All fixtures advertise tools, prompts, resources and logging capabilities, so the separately reported optional-capability issue does not apply here.
  • Evidence boundary: local mock server only; not tested against a WSO2-hosted product instance. No CVSS score is asserted.
Area / Aspect / Severity

Area: CLI. Aspect: Aspect/AI, Aspect/API and Aspect/Configuration. Severity: Severity/Major (provisional functional assessment for maintainer review).

Screenshot and attachments

Screenshot of captured CLI output showing success after HTTP 401/503 and empty generated configuration

Ngôn ngữ chính
Go
Star
85
Fork
137
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
247

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của wso2/api-platform

Tất cả issue của wso2/api-platform

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.