I think the most polite way to tell them is not to tell them what to do, but rather ask: "Could you give us more background on what you're trying to do? It might turn out we know of an alternative solution that avoids this specific problem."
This doesn't suggest that the questioner did something wrong, but still helps them learn to provide background details when asking questions.