Blueprint Message malformed

In my first attempt to create a blueprint, I want to simplify sending MQTT binary messages. If the HA button sends ‘on’ the payload “On” should be sent to the specified MQTT topic. I however get this message:

Message malformed: expected str for dictionary value @ data['action'][0]['if'][0]['state']

As far as I can see, the provided entry IS a string. What am I doing wrong?

blueprint:
    name: Control MQTT binary switches
    domain: automation
    description: Blueprint to automate switching binary MQTT devices
    input:
      light_switch:
        name: Wall switch or HA button
        selector:
          entity:
            domain: 
              - light
              - switch
      target_light:
        name: Device to be switched (MQTT topic)
      command_on:
        name: Command to send to switch ON
        selector:
            text:
                type: text
        default: "On"
      command_off:
        name: Command to send to switch OFF
        selector:
            text:
                type: text
        default: "Off"
 
mode: single
      
trigger:
  - platform: state
    entity_id: !input light_switch
condition: []
action:
  - if:
      - condition: state
        entity_id: !input light_switch
        state: "on"
    then:
      - service: mqtt.publish
        data:
          qos: 0
          retain: false
          topic: !input target_light
          payload: !input command_on
  - if:
      - condition: state
        entity_id: !input light_switch
        state: "off"
    then:
      - service: mqtt.publish
        data:
          qos: 0
          retain: false
          topic: !input target_light
          payload: !input command_off

You can’t have multiple if statements at the same level. In this case you can use if-then-else, otherwise for deeper nesting you need to use a choose statement.
Script Syntax - Home Assistant.

If this suggestion solves your problem, please consider clicking the solution button to close the thread.

Unfortunately this did not solve the problem. Same error after changing into if-then-else construct.

EDIT:
Actually both options worked after all. I failed to reload the yaml configrations in Developer Tools. After reloading the error disappered and both options (2x if statement AND if-then-else) actually work

@Sir_Goodenough thanks for taking the time to reply and apologies for my ignorance