[Bug]: A WebSub policy's executionCondition is dropped on deploy, so the policy runs on every message
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go
- Área
- backend-api-design
Línea de trabajo
Start with generatePolicyList in platform-api/plugins/eventgateway/service/websub_api_deployment.go and model.Policy in platform-api/internal/model/api.go; trace how policy fields are copied into the deployment YAML and read by the gateway. Check the deployed artifact and the gateway's GET /api/management/v1/websub-apis/{id} output. Done when the condition is preserved in the artifact and the gateway runs the policy only when it holds.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Please select the area the issue is related to
Event Gateway, Platform API
Please select the aspect the issue is related to
Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)
Description
A WebSub API's policy executionCondition is lost when the API is deployed, so the policy runs on every message. platform-api stores the condition and returns it on GET, but the deployment artifact doesn't carry it in a form the gateway reads:
allChannels:
on_message_received:
policies:
- executioncondition: null
name: log-message
params: {}
version: v1
receiver:
policies:
- executioncondition: request.header.x-run == 'yes'
name: log-message
...
The event gateway's copy of the API (GET /api/management/v1/websub-apis/b01-ws) lists the policy with no condition at all. A message published without the x-run header, so with the condition false, still ran the policy:
level=DEBUG msg="[body] calling OnRequestBody" policy=log-message version=v1 route=SUB|/b01ws/v1/webhook-receiver|*
Where it comes from in the code:
generatePolicyList(platform-api/plugins/eventgateway/service/websub_api_deployment.go:721) copies onlyName,VersionandParams, soallChannelsand per-channel policies lose the condition.model.Policy(platform-api/internal/model/api.go:100) has JSON tags only. The YAML artifact therefore writes the field asexecutionconditioninstead ofexecutionCondition, even where the value survives (thereceiversection).
Expected: a policy with an executionCondition runs only when the condition holds.
Actual: the condition is dropped and the policy always runs.
Steps to Reproduce
Setup: platform-api built with -tags experimental and an event gateway connected to it, both built from main.
Deployments to an event gateway built from
maincurrently fail because of #4288. To reproduce this issue I cleared that gateway's stored version in platform-api's database (UPDATE gateways SET version='' WHERE handle='<event-gateway-id>'). That is a test workaround.
- Create the API with a conditional policy:
POST /api/v0.9/websub-apiswith{"id":"b01-ws","displayName":"b01-ws","version":"v1","projectId":"default","context":"/b01ws","allChannels":{"on_message_received":{"policies":[{"name":"log-message","version":"v1","params":{},"executionCondition":"request.header.x-run == 'yes'"}]}},"channels":{"orders":{}}}. The201response returns theexecutionCondition. - Deploy it to the event gateway (
POST /api/v0.9/websub-apis/b01-ws/deployments,base: current). Wait forDEPLOYED. - Read the stored artifact (
SELECT content FROM deployments WHERE uuid='<deploymentId>'). The policies look as shown above. GET /api/management/v1/websub-apis/b01-wson the event gateway controller listslog-messagewith no condition.- Subscribe a callback to topic
orders(POST http://<event-gateway>:8080/b01ws/v1/hub, formhub.mode=subscribe&hub.topic=orders&hub.callback=<listener>), then publish without anx-runheader:POST http://<event-gateway>:8080/b01ws/v1/webhook-receiver?topic=orderswith{"msg":"msg-1"}. - The event-gateway runtime logs
calling OnRequestBody policy=log-message, so the policy ran although its condition is false.
Severity Level of the Issue
Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)
Environment Details (with versions)
- Source:
mainatf5c93849. - platform-api built from source with
-tags experimental(SQLite). - Event gateway images
0.10.0-SNAPSHOTbuilt from that commit; Kafkabitnamilegacy/kafka:4.0.0-debian-12-r10. - macOS with Rancher Desktop.
- Lenguaje dominante
- Go
- Estrellas
- 85
- Forks
- 137
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 247
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de wso2/api-platform
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
wso2/api-platform#4369 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: host-rewrite policy documentation lists fewer allowed host characters than the policy acceptsAbiertoArea/Policies Aspect/Other Severity/Trivial Type/Bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
wso2/api-platform#4355 ·
Los mantenedores suelen responder en 1 día
-
Area/Gateway Aspect/API Severity/Minor Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
wso2/api-platform#4348 ·
Los mantenedores suelen responder en 1 día
-
Aspect/AI Aspect/API. Severity/Major
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
wso2/api-platform#4343 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: content-length-guardrail policy accepts a non-string streamingJsonPath at API creationAbiertoArea/Policies Aspect/Configuration Severity/Minor Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
wso2/api-platform#4330 ·
Los mantenedores suelen responder en 1 día
Todos los issues de wso2/api-platform
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
needs discussion
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
openfga/openfga.dev#1436 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
都道府県を指定すると区名から始まる住所に市名を補わないAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
digital-go-jp/abr-geocoder#457 ·
Los mantenedores suelen responder en 3 días
-
benchmark
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
mozilla-ai/cq#601 ·
Los mantenedores suelen responder en 1 día