Skip to content

Flex Template Align Error #505

@FawenYo

Description

@FawenYo

System Informations

  • Go version: 1.23.2-alpine3.20
  • OS: alpine
  • Package version: github.com/line/line-bot-sdk-go/v8 v8.10.0

Expected Behavior

Here is a simple Flex message I design with the Flex Message Simulator tool

{
  "type": "bubble",
  "body": {
    "type": "box",
    "layout": "vertical",
    "contents": [
      {
        "type": "box",
        "layout": "horizontal",
        "contents": [
          {
            "type": "text",
            "text": "測試",
            "size": "sm",
            "color": "#555555",
            "flex": 0
          },
          {
            "type": "text",
            "text": "123",
            "size": "sm",
            "color": "#111111",
            "align": "end"
          }
        ]
      }
    ]
  },
  "styles": {
    "footer": {
      "separator": true
    }
  }
}

and the message should look like this

image

Current Behavior

Here is part of my Golang code

jsonString := fmt.Sprintf(`{
"type": "bubble",
"body": {
	"type": "box",
	"layout": "vertical",
	"contents": [
	{
		"type": "box",
		"layout": "horizontal",
		"contents": [
		{
			"type": "text",
			"text": "測試",
			"size": "sm",
			"color": "#555555",
			"flex": 0
		},
		{
			"type": "text",
			"text": "123",
			"size": "sm",
			"color": "#111111",
			"align": "end"
		}
		]
	}
	]
},
"styles": {
	"footer": {
	"separator": true
	}
}
}`)
		  
contents, err := messaging_api.UnmarshalFlexContainer([]byte(jsonString))
if err != nil {
	log.WithField("userName", displayName).WithField("userID", userID).Errorf("Failed to unmarshal flex container: %s", err)
	replyMessage = &messaging_api.TextMessage{
		Text: "Failed to unmarshal",
	}
}

replyMessage = &messaging_api.FlexMessage{
	AltText:  "Test",
	Contents: contents,
}
if _, err := bot.ReplyMessage(
	&messaging_api.ReplyMessageRequest{
		ReplyToken: replyToken,
		Messages:   []messaging_api.MessageInterface{replyMessage},
	},
); err != nil {
	log.WithField("userName", displayName).WithField("userID", userID).Errorf("Failed to reply message: %s", err)
}

and the sent image looks like this

image

The align format is quite different from the expected one.

Steps to Reproduce

  1. Follow the example flex message JSON above to test to send with the SDK

Logs

No obvious error log

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions