besom icon indicating copy to clipboard operation
besom copied to clipboard

besom.internal.ResourceDecoder fails to parse some escape codes

Open nikolaiser opened this issue 1 year ago • 1 comments

//> using scala "3.3.3"
//> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement
//> using dep "org.virtuslab::besom-core:0.3.1"
//> using dep "org.virtuslab::besom-command:0.10.0-core.0.3"
import besom.*
import besom.api.command

@main def main = Pulumi.run {

  val run = command.local.Command(
      "test-command",
      command.local.CommandArgs(
          create = """echo -e "normal text here \n\x1b[0;1;31m this text should be bold and red""""
        )
    )

  Stack.exports(
    stdout = run.stdout
  )
}

pulumi up fails with

 2024.05.07 00:02:40:797 scala-execution-context-global-52 [resource: test-command[command:local:Command]] ERROR besom.internal.ResourceDecoder.resolve:97
        Resolve resource: received error from gRPC call: 'Unknown ansi-escape [0;1;31m at index 21 inside string cannot be
        parsed into an fansi.Str', failing resolution
    2024.05.07 00:02:40:844 main  ERROR besom.internal.BesomModule.run:70
        java.lang.IllegalArgumentException: Unknown ansi-escape [0;1;31m at index 21 inside string cannot be parsed into an
         fansi.Str

nikolaiser avatar May 06 '24 22:05 nikolaiser

Thank you for this report! I'm wondering if this is hiding another issue as we don't really use fansi in contexts different than debugging and error handling. I'll investigate.

lbialy avatar May 08 '24 06:05 lbialy

Ok, so this is a much bigger problem than just fansi having issues with parsing some escape codes. It seems Pulumi engine does something to escape codes and even if I disable trace logging that leads to this exception the besom program does not terminate at all in your sample. I guess something goes horribly wrong on pulumi's side but I'm still researching.

lbialy avatar May 23 '24 11:05 lbialy

Ha, problem is on our side (in fansi and our pretty printer). I have a solution that works.

lbialy avatar May 23 '24 11:05 lbialy

fixed in #492

lbialy avatar May 24 '24 19:05 lbialy