[Bug]: content-length-guardrail policy counts SSE events without content as their whole JSON text
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 57/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
Hướng nghiên cứu
Start by locating the content-length-guardrail policy implementation and its tests for streaming JSONPath extraction. Reproduce the report with an SSE stream containing a content event followed by an empty delta finish event, then check how the policy handles a valid JSON event with no value at the configured path. Done means the event contributes zero bytes and the stream passes when its actual content is within the configured limits.
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
Gateway
Please select the aspect the issue is related to
Aspect/AI (AI/LLM integration, MCP, AI readiness)
Description
The content-length-guardrail policy counts an SSE event with no content as content. When an event has no value at streamingJsonPath, the policy adds the event's whole JSON text to the response length. It should add zero bytes.
Real providers send such events in every stream. OpenAI ends each stream with a finish event whose delta is empty:
data: {"choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
With the default path, $.choices[0].delta.content, this event adds 59 bytes. A stream with usage reporting adds a usage event as well. Some providers also send a first event that holds only the role.
The extra bytes change the policy's decisions:
- A reply within
maxis blocked when the extra bytes take it over. - A reply shorter than
minpasses when the extra bytes take it overmin. - The policy releases a held-back stream earlier than the content alone would.
The doc says the policy uses the JSONPath "to extract the incremental token text" from each event. An event with no token text should add nothing.
A fix could count zero bytes for an event that is valid JSON but has no value at streamingJsonPath. Whether a data line that is not JSON should still count as content is a separate choice.
The integration suite in wso2/gateway-controllers#415 asserts the current behaviour.
Steps to Reproduce
- Create a REST API with the
content-length-guardrailpolicy on an operation:{"name":"content-length-guardrail","version":"v1","params":{"response":{"enabled":true,"min":1,"max":20}}} - Send a request whose upstream replies with this SSE stream. Its only content is
abc, 3 bytes:data: {"choices":[{"delta":{"content":"abc"}}]} data: {"choices":[{"index":0,"delta":{},"finish_reason":"stop"}]} data: [DONE] - The stream ends with the guardrail's SSE error event, and
[DONE]never reaches the client. The policy counts 62 bytes: 3 forabcand 59 for the finish event. - Send the same stream without the finish event. It passes with
abcand[DONE].
Severity Level of the Issue
Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)
Environment Details (with versions)
- Policy:
content-length-guardrailv1.1.0, wso2/gateway-controllers main (4f1520a8) - Gateway versions: 1.1.0 (patched), 1.2.0 and latest (
main-59dcd51) - macOS 27.0.1 (Apple silicon), Colima 0.10.3, Docker Engine 29.5.2
- 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ự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
needs discussion
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openfga/openfga.dev#1436 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
都道府県を指定すると区名から始まる住所に市名を補わないĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
digital-go-jp/abr-geocoder#457 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
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