support icon indicating copy to clipboard operation
support copied to clipboard

[Bug] Uncatched error on code.pybricks.com on loading a block-code program with an unsupported block

Open BertLindeman opened this issue 1 year ago • 5 comments

Describe the bug Tried to load the program example for discussion #1558 on code.pybricks.com. The source uses an xbox rumble, not yet supported on code.pybricks.com. Results in repeated reloading of the panels. Hard to catch the error as it does not stay visible long enough.

To reproduce Steps to reproduce the behavior:

  1. Go to code.pybricks.com
  2. Load issue_1588.py (in my case)
  3. Select that source in the left bar
  4. See looping reload error
  5. Can select the source on the left side to delete, do get the confirm delete. But it does not go away.

Expected behavior What did you expect to happen instead? Maybe some simple user error: "feature not supported (yet)"

repair action I do not know how to recover from this loop 😢

Screenshots issue_1588.py image pybricks_program_2024-04-07T07_24_27

Photo of the error: 2024-04-07 09 34 43

The python source

click to unfold ```python # pybricks blocks file:{"blocks":{"languageVersion":0,"blocks":[{"type":"blockGlobalSetup","id":"bjK,wS1MYO7aiYkFSwd{","x":19,"y":105,"deletable":false,"next":{"block":{"type":"variables_set_xbox_controller","id":"adSc}Uq)-FH52Eqw4BU%","fields":{"VAR":{"id":"qYn:HSWf!cj|8ISoJgA."}}}}},{"type":"blockGlobalStart","id":"3tJe|AWl0baN(wH9a$@.","x":159,"y":107,"deletable":false,"next":{"block":{"type":"blockFlowWhile","id":"jtg7*#es/L8]{:oQlUed","fields":{"MODE":"WHILE"},"inputs":{"BOOL":{"shadow":{"type":"blockLogicTrue","id":",k;jM@as_ZsID.=O28z="}},"DO":{"block":{"type":"blockIfElse","id":"{]X^K`%EjMuYP#ABgpL[","extraState":{"optionLevel":3},"inputs":{"IF0":{"shadow":{"type":"blockLogicTrue","id":"M|8;hQz:m#LnlZAJll5m"},"block":{"type":"blockButtonIsPressed","id":"ab8zh4tn!2.W%m_oTE?D","inputs":{"VAR":{"shadow":{"type":"variables_get_keypad","id":"6.B0b*e:nd=,#=kMbU4N","fields":{"VAR":{"id":"qYn:HSWf!cj|8ISoJgA.","name":"xbox","type":"XboxController"}}}},"VALUE0":{"shadow":{"type":"blockParametersButton","id":"_Mrw_.6V+=HI~6M+9Aje","fields":{"VALUE":"A"}}}}}},"DO0":{"block":{"type":"blockPrint","id":"j,,T}?rBkaW$1v?olp4p","extraState":{"optionLevel":0},"inputs":{"TEXT0":{"shadow":{"type":"text","id":"!x5.0YiWya^`(y)yO5B8","fields":{"TEXT":"\"A\""}}}}}},"IF1":{"shadow":{"type":"blockLogicTrue","id":"6T/|Nu2%|!!u[7@K{t*F"},"block":{"type":"blockButtonIsPressed","id":";=v)z0rc]Y$D-,OR2JI{","inputs":{"VAR":{"shadow":{"type":"variables_get_keypad","id":")}VsZ!7BhWxI%QR,ZT%a","fields":{"VAR":{"id":"qYn:HSWf!cj|8ISoJgA.","name":"xbox","type":"XboxController"}}}},"VALUE0":{"shadow":{"type":"blockParametersButton","id":"X]`,dzv%bu#E5}4}2u=n","fields":{"VALUE":"Y"}}}}}},"DO1":{"block":{"type":"blockPrint","id":"{/(IsTa6vYBMdPh_bQOQ","extraState":{"optionLevel":0},"inputs":{"TEXT0":{"shadow":{"type":"text","id":"M}`0bmh#_5bHj3G=@(7W","fields":{"TEXT":"\"Y\""}}}}}},"IF2":{"shadow":{"type":"blockLogicTrue","id":"9`wn/oTRS[VwWTrW2`qu"},"block":{"type":"blockButtonIsPressed","id":"5eXAg3L?E?}+znuJAi3@","inputs":{"VAR":{"shadow":{"type":"variables_get_keypad","id":"q]L=@6XGKZrXYkX_*-Xa","fields":{"VAR":{"id":"qYn:HSWf!cj|8ISoJgA.","name":"xbox","type":"XboxController"}}}},"VALUE0":{"shadow":{"type":"blockParametersButton","id":"!@ExDeLxSRiO[x;$;qS_","fields":{"VALUE":"LB"}}}}}},"DO2":{"block":{"type":"blockGamepadRumble","id":"W:xALPI{tqWSLV=n7r{$","extraState":{"optionLevel":0},"inputs":{"VAR":{"shadow":{"type":"variables_get_gamepad","id":"SIKm#mGB$4ANuq;JRX7}","fields":{"VAR":{"id":"qYn:HSWf!cj|8ISoJgA.","name":"xbox","type":"XboxController"}}}},"VALUE0":{"shadow":{"type":"unit_percent","id":"wKSyb]OU|):RYs(oVegB","fields":{"VALUE0":100}}},"VALUE1":{"shadow":{"type":"unit_time","id":"(/)tPVVis?2[1Z/PG`eu","fields":{"VALUE0":100}}}},"next":{"block":{"type":"blockWaitTime","id":"p,c3!fimcgFH3BD_HQ_%","inputs":{"VALUE0":{"shadow":{"type":"unit_time","id":"$oz)zIAIEvKrt:.cmzPY","fields":{"VALUE0":200}}}}}}}}},"next":{"block":{"type":"blockWaitTime","id":"B5{HldR;_zh!+cy@.}q@","inputs":{"VALUE0":{"shadow":{"type":"unit_time","id":"jA]K{x9hLe#X+@!Xw4w}","fields":{"VALUE0":200}}}}}}}}}}}}]},"variables":[{"name":"red","id":"P0=yr-cS3u6o11WFHxzD","type":"ColorDef"},{"name":"orange","id":"TLJhiKm^RztKj0H-YL8)","type":"ColorDef"},{"name":"yellow","id":"B+)Y{259u+~kFI`Ikvtv","type":"ColorDef"},{"name":"green","id":"@E1{k|tbG6xgK;fK.wRr","type":"ColorDef"},{"name":"cyan","id":"!o2PQPS0==Kv$6%qo[Vx","type":"ColorDef"},{"name":"blue","id":"+sbOY:r$$J2NN)nCft*v","type":"ColorDef"},{"name":"violet","id":"nCP-f23G~GLMehgqzWzK","type":"ColorDef"},{"name":"magenta","id":":41%i$RC#TtH6Z`ko[(a","type":"ColorDef"},{"name":"white","id":"rZcE?|r*i-JBhc3zKw@_","type":"ColorDef"},{"name":"none","id":"q{?[Ox^0}40=bf/^/~?r","type":"ColorDef"},{"name":"buttons","id":"cLG?QTut`2pou(C3h6(P","type":"Remote"},{"name":"xbox","id":"qYn:HSWf!cj|8ISoJgA.","type":"XboxController"},{"name":"controller","id":"o0[5#+i`mHftHbPvD{;,","type":"XboxController"}],"info":{"type":"pybricks","version":"1.2.0"}} from pybricks.iodevices import XboxController from pybricks.parameters import Button from pybricks.tools import wait

Set up all devices.

xbox = XboxController()

The main program starts here.

while True: if Button.A in xbox.buttons.pressed(): print('"A"') elif Button.Y in xbox.buttons.pressed(): print('"Y"') elif Button.LB in xbox.buttons.pressed(): xbox.rumble(100, 100) wait(200) else: pass wait(200)

</details>

BertLindeman avatar Apr 07 '24 07:04 BertLindeman

Did get a screenshot. Maybe some other data? afbeelding

BertLindeman avatar Apr 07 '24 07:04 BertLindeman

After ample time (I did not do anything on the code.pybricks.com session:

The program failed to load. Please open an issue over at:

https://github.com/pybricks/support

and include the following snippet in your post:

{
  "blocks": {
    "languageVersion": 0,
    "blocks": [
      {
        "type": "blockGlobalSetup",
        "id": "bjK,wS1MYO7aiYkFSwd{",
        "x": 19,
        "y": 105,
        "deletable": false,
        "next": {
          "block": {
            "type": "variables_set_xbox_controller",
            "id": "adSc}Uq)-FH52Eqw4BU%",
            "fields": {
              "VAR": {
                "id": "qYn:HSWf!cj|8ISoJgA."
              }
            }
          }
        }
      },
      {
        "type": "blockGlobalStart",
        "id": "3tJe|AWl0baN(wH9a$@.",
        "x": 159,
        "y": 107,
        "deletable": false,
        "next": {
          "block": {
            "type": "blockFlowWhile",
            "id": "jtg7*#es/L8]{:oQlUed",
            "fields": {
              "MODE": "WHILE"
            },
            "inputs": {
              "BOOL": {
                "shadow": {
                  "type": "blockLogicTrue",
                  "id": ",k;jM@as_ZsID.=O28z="
                }
              },
              "DO": {
                "block": {
                  "type": "blockIfElse",
                  "id": "{]X^K`%EjMuYP#ABgpL[",
                  "extraState": {
                    "optionLevel": 3
                  },
                  "inputs": {
                    "IF0": {
                      "shadow": {
                        "type": "blockLogicTrue",
                        "id": "M|8;hQz:m#LnlZAJll5m"
                      },
                      "block": {
                        "type": "blockButtonIsPressed",
                        "id": "ab8zh4tn!2.W%m_oTE?D",
                        "inputs": {
                          "VAR": {
                            "shadow": {
                              "type": "variables_get_keypad",
                              "id": "6.B0b*e:nd=,#=kMbU4N",
                              "fields": {
                                "VAR": {
                                  "id": "qYn:HSWf!cj|8ISoJgA.",
                                  "name": "xbox",
                                  "type": "XboxController"
                                }
                              }
                            }
                          },
                          "VALUE0": {
                            "shadow": {
                              "type": "blockParametersButton",
                              "id": "_Mrw_.6V+=HI~6M+9Aje",
                              "fields": {
                                "VALUE": "A"
                              }
                            }
                          }
                        }
                      }
                    },
                    "DO0": {
                      "block": {
                        "type": "blockPrint",
                        "id": "j,,T}?rBkaW$1v?olp4p",
                        "extraState": {
                          "optionLevel": 0
                        },
                        "inputs": {
                          "TEXT0": {
                            "shadow": {
                              "type": "text",
                              "id": "!x5.0YiWya^`(y)yO5B8",
                              "fields": {
                                "TEXT": "\"A\""
                              }
                            }
                          }
                        }
                      }
                    },
                    "IF1": {
                      "shadow": {
                        "type": "blockLogicTrue",
                        "id": "6T/|Nu2%|!!u[7@K{t*F"
                      },
                      "block": {
                        "type": "blockButtonIsPressed",
                        "id": ";=v)z0rc]Y$D-,OR2JI{",
                        "inputs": {
                          "VAR": {
                            "shadow": {
                              "type": "variables_get_keypad",
                              "id": ")}VsZ!7BhWxI%QR,ZT%a",
                              "fields": {
                                "VAR": {
                                  "id": "qYn:HSWf!cj|8ISoJgA.",
                                  "name": "xbox",
                                  "type": "XboxController"
                                }
                              }
                            }
                          },
                          "VALUE0": {
                            "shadow": {
                              "type": "blockParametersButton",
                              "id": "X]`,dzv%bu#E5}4}2u=n",
                              "fields": {
                                "VALUE": "Y"
                              }
                            }
                          }
                        }
                      }
                    },
                    "DO1": {
                      "block": {
                        "type": "blockPrint",
                        "id": "{/(IsTa6vYBMdPh_bQOQ",
                        "extraState": {
                          "optionLevel": 0
                        },
                        "inputs": {
                          "TEXT0": {
                            "shadow": {
                              "type": "text",
                              "id": "M}`0bmh#_5bHj3G=@(7W",
                              "fields": {
                                "TEXT": "\"Y\""
                              }
                            }
                          }
                        }
                      }
                    },
                    "IF2": {
                      "shadow": {
                        "type": "blockLogicTrue",
                        "id": "9`wn/oTRS[VwWTrW2`qu"
                      },
                      "block": {
                        "type": "blockButtonIsPressed",
                        "id": "5eXAg3L?E?}+znuJAi3@",
                        "inputs": {
                          "VAR": {
                            "shadow": {
                              "type": "variables_get_keypad",
                              "id": "q]L=@6XGKZrXYkX_*-Xa",
                              "fields": {
                                "VAR": {
                                  "id": "qYn:HSWf!cj|8ISoJgA.",
                                  "name": "xbox",
                                  "type": "XboxController"
                                }
                              }
                            }
                          },
                          "VALUE0": {
                            "shadow": {
                              "type": "blockParametersButton",
                              "id": "!@ExDeLxSRiO[x;$;qS_",
                              "fields": {
                                "VALUE": "LB"
                              }
                            }
                          }
                        }
                      }
                    },
                    "DO2": {
                      "block": {
                        "type": "blockGamepadRumble",
                        "id": "W:xALPI{tqWSLV=n7r{$",
                        "extraState": {
                          "optionLevel": 0
                        },
                        "inputs": {
                          "VAR": {
                            "shadow": {
                              "type": "variables_get_gamepad",
                              "id": "SIKm#mGB$4ANuq;JRX7}",
                              "fields": {
                                "VAR": {
                                  "id": "qYn:HSWf!cj|8ISoJgA.",
                                  "name": "xbox",
                                  "type": "XboxController"
                                }
                              }
                            }
                          },
                          "VALUE0": {
                            "shadow": {
                              "type": "unit_percent",
                              "id": "wKSyb]OU|):RYs(oVegB",
                              "fields": {
                                "VALUE0": 100
                              }
                            }
                          },
                          "VALUE1": {
                            "shadow": {
                              "type": "unit_time",
                              "id": "(/)tPVVis?2[1Z/PG`eu",
                              "fields": {
                                "VALUE0": 100
                              }
                            }
                          }
                        },
                        "next": {
                          "block": {
                            "type": "blockWaitTime",
                            "id": "p,c3!fimcgFH3BD_HQ_%",
                            "inputs": {
                              "VALUE0": {
                                "shadow": {
                                  "type": "unit_time",
                                  "id": "$oz)zIAIEvKrt:.cmzPY",
                                  "fields": {
                                    "VALUE0": 200
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  },
                  "next": {
                    "block": {
                      "type": "blockWaitTime",
                      "id": "B5{HldR;_zh!+cy@.}q@",
                      "inputs": {
                        "VALUE0": {
                          "shadow": {
                            "type": "unit_time",
                            "id": "jA]K{x9hLe#X+@!Xw4w}",
                            "fields": {
                              "VALUE0": 200
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    ]
  },
  "variables": [
    {
      "name": "red",
      "id": "P0=yr-cS3u6o11WFHxzD",
      "type": "ColorDef"
    },
    {
      "name": "orange",
      "id": "TLJhiKm^RztKj0H-YL8)",
      "type": "ColorDef"
    },
    {
      "name": "yellow",
      "id": "B+)Y{259u+~kFI`Ikvtv",
      "type": "ColorDef"
    },
    {
      "name": "green",
      "id": "@E1{k|tbG6xgK;fK.wRr",
      "type": "ColorDef"
    },
    {
      "name": "cyan",
      "id": "!o2PQPS0==Kv$6%qo[Vx",
      "type": "ColorDef"
    },
    {
      "name": "blue",
      "id": "+sbOY:r$$J2NN)nCft*v",
      "type": "ColorDef"
    },
    {
      "name": "violet",
      "id": "nCP-f23G~GLMehgqzWzK",
      "type": "ColorDef"
    },
    {
      "name": "magenta",
      "id": ":41%i$RC#TtH6Z`ko[(a",
      "type": "ColorDef"
    },
    {
      "name": "white",
      "id": "rZcE?|r*i-JBhc3zKw@_",
      "type": "ColorDef"
    },
    {
      "name": "none",
      "id": "q{?[Ox^0}40=bf/^/~?r",
      "type": "ColorDef"
    },
    {
      "name": "buttons",
      "id": "cLG?QTut`2pou(C3h6(P",
      "type": "Remote"
    },
    {
      "name": "xbox",
      "id": "qYn:HSWf!cj|8ISoJgA.",
      "type": "XboxController"
    },
    {
      "name": "controller",
      "id": "o0[5#+i`mHftHbPvD{;,",
      "type": "XboxController"
    }
  ],
  "info": {
    "type": "pybricks",
    "version": "1.2.0"
  }
}

BertLindeman avatar Apr 07 '24 08:04 BertLindeman

The program failed to load. Please open an issue.

This is currently the expected result. It isn't supposed to endlessly restart, though.

In the long run, I'd like failed programs to automatically open in an archived version of the block editor, so you could never lose your programs. (As opposed to saying "heads up, couldn't open", as in the official app).

This is already happening in that you get the json instead of hiding it, but it isn't terribly helpful if there isn't currently away to open it in the visual editor.

laurensvalk avatar Apr 07 '24 10:04 laurensvalk

The looping interface was worrying me. But time fixes it. So no worries.

BertLindeman avatar Apr 07 '24 11:04 BertLindeman

What it should probably do in the future is:

  • Explain that the program could not be opened and why (e.g. these new blocks not yet available)
  • Generate a screenshot of the original program using the version of Pybricks Blocks that was used to create it, so you'd always be able to see the original and recreate in any version

laurensvalk avatar Apr 07 '24 11:04 laurensvalk