Exactly. Your "Remove trailing whitespace" setting is most likely enabled, but the bug I introduced in 17.0.1 is inhibiting that setting for the syntax expansion case. A plain old beautify or beautify-selection should honor the setting.
It's not hot-fixable, but the fix will be in the 17.0.2 point release.