go-lark / lark

An easy-to-use SDK for Feishu and Lark Open Platform (Instant Messaging API only)
https://go-lark.github.io/
MIT License
199 stars 30 forks source link

Struct PostNotificationV2Resp dose not has BaseResponse message #21

Closed machinly closed 2 years ago

machinly commented 2 years ago

Struct PostNotificationV2Resp dose not has BaseResponse. This hides some error information, which may confuse users.

crispgm commented 2 years ago

Lark Open Platform does return this. I think we'd better respect to its field name.

machinly commented 2 years ago

BaseResponse will return in bad response. Success Request:

curl -X POST -H "Content-Type: application/json" \
 -d '{"msg_type":"interactive","card":{"config":{"wide_screen_mode":true},"elements":[]}}' \
 https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx

Success Response:

{
  "Extra":null,
  "StatusCode":0,
  "StatusMessage":"success"
}

Bad Request (without elements):

curl -X POST -H "Content-Type: application/json" \
 -d '{"msg_type":"interactive","card":{"config":{"wide_screen_mode":true}}}' \
 https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx

Bad Resonse:

{
  "code": 11246,
  "data": {},
  "msg": "msg: elements/i18n_elements should not be empty, code: 100000"
}
crispgm commented 2 years ago

BaseResponse will return in bad response. Success Request:

curl -X POST -H "Content-Type: application/json" \
 -d '{"msg_type":"interactive","card":{"config":{"wide_screen_mode":true},"elements":[]}}' \
 https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx

Success Response:

{
  "Extra":null,
  "StatusCode":0,
  "StatusMessage":"success"
}

Bad Request (without elements):

curl -X POST -H "Content-Type: application/json" \
 -d '{"msg_type":"interactive","card":{"config":{"wide_screen_mode":true}}}' \
 https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx

Bad Resonse:

{
  "code": 11246,
  "data": {},
  "msg": "msg: elements/i18n_elements should not be empty, code: 100000"
}

Okay, this is weird. So we can basically add BaseResponse and it works, but with weird behavior.

Though notifications seldom get error in return, I think it is necessary to add BaseResponse for that.

crispgm commented 2 years ago

Thanks for fixing this.