Unfortunately, bleeding it is the first thing to try.
It's common for new bikes out of the box with hydraulics to require bleeding. Shops do it frequently during assembly, or good ones do at least. Factories don't do it consistently perfectly. There are a bunch of possible reasons, mostly boiling down to time.
Shops handle a lot of bikes and have their own time pressures. Letting a new brake through that needs a bleed is an easy mistake. That rear hydraulic STIs veer towards a long and not-the-firmest lever stroke anyway doesn't help.
Checking torque on the hose fittings at each end is also prudent, but probably not the problem.
The STI bleeding procedure has some steps involving lever positioning that need to be followed to do an exhaustive job. It's not difficult but it is different from MTB systems. Hopefully you'll be able to get it done under warranty by a judicious mechanic. If not I recommend following the procedure exactly for your brake from the dealer manual you can find at si.shimano.com.
Defective ceramic pistons are hopefully not the problem, but they do happen with the Shimano road hydros. If pad/piston movement doesn't seem right after bleeding, that's the next thing to investigate. The telling symptom for issues with them is stubborn or inconsistent piston movement combined with a crunchy feeling when resetting the piston. There are questions here about this.