Jesus never sinned.
He could not have, or rather would not have, done *misdeeds* or mischievous things.
The story from the Gospel of Thomas come at a moment when Jesus is still a young boy, so he is not committing sin against sabbath law. Joseph reproves him gently as a way of instructing him in the importance of sabbath. And, as I pointed out, Joseph imposes no punishment.