-
Notifications
You must be signed in to change notification settings - Fork 241
Open
Labels
Description
System Informations
- Go version: go1.22.5 darwin/arm64
- OS: macOS 14.4.1
Expected Behavior
{
"type": "flex",
"contents": {
"type": "bubble",
"header": {
"type": "box",
"layout": "vertical",
"contents": []
},
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "box",
"layout": "baseline",
"contents": [],
"spacing": "sm"
},
{
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "box",
"layout": "baseline",
"contents": [],
"spacing": "sm"
}
]
}
]
}
}
}
↓
{
"type": "flex",
"altText": "",
"contents": {
"type": "bubble",
"header": {
"layout": "vertical",
"flex": 0,
"type": "box",
"contents": []
},
"body": {
"layout": "vertical",
"flex": 0,
"type": "box",
"contents": [
{
"type": "box",
"layout": "baseline",
"flex": 0,
"contents": null,
"spacing": "sm"
},
{
"type": "box",
"layout": "vertical",
"flex": 0,
"contents": [
{
"type": "box",
"layout": "baseline",
"flex": 0,
"contents": [], // is should empty?
"spacing": "sm"
}
]
}
]
}
}
}
Current Behavior
The contents
value of type box
of flex message contents is encoded to null
when it is nested and empty. So narrowcast API returns May not be empty
.
I think it is necessary to modify the unmarshal logic in linebot/messaging_api/model_flex_box.go
.
If this approach is acceptable, I would like to proceed with submitting a pull request. Please let me know if there are any concerns or suggestions for improvement.
{
"type": "flex",
"altText": "",
"contents": {
"type": "bubble",
"header": {
"layout": "vertical",
"flex": 0,
"type": "box",
"contents": []
},
"body": {
"layout": "vertical",
"flex": 0,
"type": "box",
"contents": [
{
"type": "box",
"layout": "baseline",
"flex": 0,
"contents": null,
"spacing": "sm"
},
{
"type": "box",
"layout": "vertical",
"flex": 0,
"contents": [
{
"type": "box",
"layout": "baseline",
"flex": 0,
"contents": null, // `[]` is encoded to `null`
"spacing": "sm"
}
]
}
]
}
}
}
Steps to Reproduce
flex2 := `{
"type": "flex",
"contents": {
"type": "bubble",
"header": {
"type": "box",
"layout": "vertical",
"contents": []
},
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "box",
"layout": "baseline",
"contents": [],
"spacing": "sm"
},
{
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "box",
"layout": "baseline",
"contents": [],
"spacing": "sm"
}
]
}
]
}
}
}`
f2, err := messaging_api.UnmarshalMessage([]byte(flex2))
if err != nil {
fmt.Println(err)
}
ff2, _ := json.MarshalIndent(f2, "", " ")
fmt.Println(string(ff2))