Aggregate by on str dim err handling

A replacement for #461 (reproduces exactly what was there prior to the rebase).