My car's check engine light is on and now there's a weird rattling noise
That sounds serious a check engine light with a rattling noise is not something to ignore and it could get worse fast.
If the noise is from the front end a loose heat shield or suspension part could be the culprit a quick diagnostic will tell you what needs fixing.
In my experience a generic scanner code can be misleading so ask for a full diagnostic and avoid driving far until you know its safe.
Best move is to book a shop you trust and have them check it under warranty or as needed and keep an eye on how the car drives.