[Bug]: An invalid vhost on a platform-api deployment returns 500 instead of a validation error
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/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
- api, backend-api-design
Hướng nghiên cứu
Bắt đầu tại platform-api/internal/service/deployment.go quanh các dòng 331–357, nơi các giá trị vhostMain và vhostSandbox không hợp lệ bị từ chối. So sánh với lỗi xác thực hiện có cho base quanh các dòng 188–191 và kiểm tra cách platform-api/internal/handler/service_error.go ánh xạ lỗi dịch vụ. Công việc hoàn tất khi các vhost không hợp lệ trả về lỗi xác thực 400 nêu tên trường và lý do, trong khi _gateway_default_ vẫn được chấp nhận.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Please select the area the issue is related to
Platform API
Please select the aspect the issue is related to
Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)
Description
Deploying a REST API through platform-api with an invalid metadata.vhostMain or metadata.vhostSandbox returns 500 INTERNAL_ERROR ("An unexpected error occurred."). It should return a 400 that names the invalid vhost. The value is a caller mistake, but the caller is told the server failed and is given no hint about what to fix.
Observed (POST /api/v0.9/rest-apis/{id}/deployments with base: current and a gatewayId)
metadata.vhostMain: "bad_host":500 {"code":"INTERNAL_ERROR","message":"An unexpected error occurred."}metadata.vhostMain: "-api.example.com"(leading hyphen): the same 500.metadata.vhostMainwith a 64-character label: the same 500.metadata.vhostSandbox: "bad_host": the same 500.metadata.vhostMain: "_gateway_default_": 201, as expected.
Expected
A 400 with a validation error code and a message that says which vhost is invalid and why, as other deployment validation errors do (for example REST_API_DEPLOYMENT_VALIDATION_FAILED).
Cause
platform-api/internal/service/deployment.go:331-357 rejects the value with a plain fmt.Errorf("invalid vhostMain in metadata: %s", …) (and the same for vhostSandbox, and for a non-string value). That is not a catalog error, so serviceError (platform-api/internal/handler/service_error.go:41-46) maps it to apperror.Internal. Using apperror.RESTAPIDeploymentValidationFailed.New(...) there, as deployment.go:188-191 already does for base, would return a 400.
Steps to Reproduce
- Create a REST API in platform-api and attach a connected gateway to it (
POST /api/v0.9/rest-apis/{id}/gateways). - Send
POST /api/v0.9/rest-apis/{id}/deploymentswith{"name": "d1", "base": "current", "gatewayId": "<gateway id>", "metadata": {"vhostMain": "bad_host"}}. - The response is
500 INTERNAL_ERROR.
Severity Level of the Issue
Severity/Minor (Non-critical functionality. Can be fixed in future releases)
Environment Details (with versions)
Current main (e90cde473). Platform-api and gateway built from source and run by the IT suite (tests/framework), on macOS with Rancher Desktop.
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của wso2/api-platform
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
wso2/api-platform#4369 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: host-rewrite policy documentation lists fewer allowed host characters than the policy acceptsĐang mởArea/Policies Aspect/Other Severity/Trivial Type/Bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
wso2/api-platform#4355 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Area/Gateway Aspect/API Severity/Minor Type/Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
wso2/api-platform#4348 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Aspect/AI Aspect/API. Severity/Major
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
wso2/api-platform#4343 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: content-length-guardrail policy accepts a non-string streamingJsonPath at API creationĐang mởArea/Policies Aspect/Configuration Severity/Minor Type/Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
wso2/api-platform#4330 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của wso2/api-platform
Issue tương tự
-
benchmark
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
mozilla-ai/cq#601 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation migration
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày