We're generating painless scripts from higher-level condition representations. One obvious workaround there is to prevent the generator from outputting the condition in the first place, when the block would be empty. Or, add a no-op like "true", as above. Or, like you say, re-write to remove the whole "if".
Certainly, this is not a bug. I think it's just odd. Don't have practically all bracket-style languages a definition for "block-statement" like "block-statement := { statement-list }" with "statement-list := empty, or a statement-list followed by a statement".
Well, Painless apparently does not. Fair enough, NP. Of course, the purpose of this note is to help anyone wondering about the error message "Extraneous if statement" (like Painless is a pain in my head and https://stackoverflow.com/q/50211148)