apache / apache/apisix-python-plugin-runner

Exception Handling

Đang mở
#56 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
42
Fork
24
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hello,
What is the intended behaviour of a plugin raising an exception?

e.g.

```
"plugins": {
"ext-plugin-pre-req": {
"allow_degradation": false,
"conf": [
{
"name": "netsuite-authenticator",
"value": "this is invalid json config"
}
]
}
}
```

```
def config(self, conf: Any) -> Any:
"""
Parse plugin configuration
:param conf:
:return:
"""
try:
conf_json = json.loads(conf)
except ValueError as e:
raise Exception("Configuration is invalid json")

return conf_json
```

```
2022-10-07 07:11:42,257 - INFO - request type:2, len:1792
2022-10-07 07:11:42,260 - ERROR - execute plugin `netsuite-authenticator` AnyError, ('Configuration is invalid json',)
2022-10-07 07:11:42,260 - INFO - response type:2, len:16
```

However **apisix ignores the plugin and continues with the request to the upstream**. This same occurs even if the exception is thrown in the filter() method.

I would prefer the ability to control this behaviour and I was expecting `allow_degredation` in apisix config to control the behaviour, but it seems this only apply to the plugin runner process itself, not errors from the plugin.

In some cases I also see the following errors immediately after the starting the plugin in dev mode due to the config token caching mechanism.

```
2022-10-07 07:37:13,104 - INFO - request type:2, len:1792
2022-10-07 07:37:13,106 - ERROR - token `1` cache acquisition failed
2022-10-07 07:37:13,106 - INFO - response type:2, len:16
```

Again, apisix ignores the plugin and continues with the request to the upstream, but I would rather it didn't.

I believe this is happening because the plugin runner is always returning a successful RPC response, but the "action" in the response isn't set to either stop or rewrite, so apisix just assumes the plugin didn't want to do anything.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

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.