Preheat the oven to 400°F (200°C). Line a baking tray with parchment or lightly oil it.
Wash the sweet potatoes and pierce each a few times with a fork to allow steam to escape. Place them on the prepared baking tray.
Roast the sweet potatoes for 45 to 50 minutes, or until a fork slides in easily and the flesh is tender when squeezed.
While the potatoes are roasting, heat 2 tablespoons olive oil in a large skillet over medium heat. Add the finely chopped onion and cook for 3 to 4 minutes, stirring occasionally, until softened and translucent.
Add the minced garlic and sliced mushrooms to the skillet. Cook for 6 to 7 minutes, stirring often, until the mushrooms release their moisture and begin to brown around the edges.
Stir in the fresh spinach and chopped rosemary. Cook for another 2 to 3 minutes, just until the spinach wilts and blends into the mushrooms. Season with salt, pepper, and a pinch of chili flakes if using. Taste and adjust seasoning.
When the sweet potatoes are tender, remove them from the oven and slice them open lengthwise. Gently mash the flesh slightly with a fork to create a cradle for the filling.
Spoon the sautéed mushroom and spinach mixture into each sweet potato, dividing it evenly. Top each filled potato with crumbled feta.
Return the stuffed sweet potatoes to the oven and bake for 5 to 7 minutes, until the feta is warmed through and starts to turn lightly golden.
Remove from the oven and serve hot.
Notes
Store leftover stuffed sweet potatoes in an airtight container for up to 3–4 days. Reheat in a 350°F (175°C) oven for 10–15 minutes until warmed through.