51

I asked this question today which, based on the comments I now suspect is an XY question. A good solution to X was put to me in the comments which solves my problem, but Y remains largely unresolved. I see a few options:

1. Edit the question to ask X. Accept an answer that addresses X.

This would make all the current answers irrelevant. It might just be easier to ask a new question about X.

2. Vote to close the question.

I'm not terribly sure what I'd close it for though. None of the options really fit.

3. Accept an answer that resolves Y.

Surely this would just encourage bad practices for anyone visiting the question later.

4. Post an answer that explains why Y is the wrong solution and how X can be solved. Accept my own answer.

This seems like an alright solution, but going outside the scope of the original question feels dirty.

5. Delete the question

If I found myself in this situation, there's bound to be someone else asking this. I feel like there could be some value for someone.


What exactly is the right thing to do here?

11
  • 10
    Your premise "If I found myself in this situation, there's bound to be someone else asking this" is flawed. I've found myself solving problems in the past that I bet no one will ever need to reproduce, mainly because I was being dumb. But, I would accept the answer that best answers the question asked, whether or not it solved the problem that you were truly trying to solve. If after going through the whole Q&A rigmarole you find that you asked the wrong question, then you should then ask a new question about what you really want.
    – user4639281
    Commented Oct 20, 2015 at 21:26
  • 5
    I would delete it, as it doesn't fit any of the close reasons, but also isn't very useful.
    – Kevin B
    Commented Oct 20, 2015 at 21:32
  • 4
    I like options 1 and 4.
    – ryanyuyu
    Commented Oct 20, 2015 at 21:42
  • 3
    I like option 4 since this is the least damaging one and feels the most correct one. I don’t think going outside the scope isn’t such a big issue in this case. Commented Oct 20, 2015 at 22:48
  • 2
    You don't have to accept an answer. Many people will answer exactly what was asked regardless of whether it is a good practice or not .... it's analogous to .... the client (OP ) knows best
    – charlietfl
    Commented Oct 20, 2015 at 23:07
  • 2
    Option 1 is totally inappropriate if you've received answers already, as it would invalidate those answers and could quite probably have an adverse impact on the reputation of those who posted the answers. (It also tends to make them look pretty foolish, which is a good way to both really tick them off and to discourage others from helping you in the future.)
    – Ken White
    Commented Oct 21, 2015 at 0:32
  • What about "Edit down the question to that X or Y that the answers address"?
    – Bergi
    Commented Oct 21, 2015 at 0:53
  • I would like to point out the scenario, I am trying to do X because of constraints 1, 2 and 3 on me and I acknowledge that Y may be the best way to go for most of the readership who don't have these constraints. For example, forced to use an old version of a language or utility due to work constraints or "legacy code". So sometimes, the OP needs X whereas it is not the best solution to the problem.
    – demongolem
    Commented Oct 22, 2015 at 17:55
  • 3
    @TinyGiant You vastly underestimate the chance that other people are dumb.
    – TylerH
    Commented Oct 22, 2015 at 18:22
  • @TylerH - They would have to be dumb, >>and<< to search then find the question with the XY problem, >>and<< recognize it as the same problem as theirs.
    – Stephen C
    Commented Feb 26, 2017 at 14:18
  • @StephenC Google has trained people to just use the first result they find.
    – Braiam
    Commented Feb 1, 2019 at 13:33

4 Answers 4

43

1b. Ask a new question based on the underlying question you've discovered, linking to the previous one as an aside if it seems useful (read: has sufficiently upvoted answers), or deleting the original otherwise.

If you leave the previous question, you should also consider editing in a short postscript to explain the reason this actually turned out to be the wrong question to ask in your case.

9
  • 2
    Man, I had never thought of this and I've found myself in this situation more than once. Commented Oct 20, 2015 at 22:53
  • 3
    "you should also consider editing in a short postscript to explain the reason this actually turned out to be the wrong question to ask in your case." I disagree. It's likely to be more noisy than interesting. Just keep your XY issue abstracted away. You asked a question you didn't mean to ask. Deal with it — leave it up, as if you did mean to ask it. Act as if everything's fine. There is no reason to clutter the original question with noise about the new one you realise you now need to ask. Commented Oct 22, 2015 at 18:04
  • This will make a mess of search results for people looking "how to solve X". It's preferable that questions ask directly about X rather than Y, as X is a generic problem, while Y's has several ramifications for each X.
    – Braiam
    Commented Feb 25, 2017 at 15:55
  • @Braiam: I really don't see how it could, if both questions link to the other. This can only possibly improve searchability and clarity. Commented Feb 25, 2017 at 20:48
  • Remember that people jump to the answer, we trained them to do so. They read the question when the answer makes no sense (if they don't just hit back). So, such "benefit" is lost. It's better that a answer about "X" to a question about "X", not using artifacts that doesn't help.
    – Braiam
    Commented Feb 25, 2017 at 20:57
  • @Braiam: So the fact that there is an indexable question about X directly in my recommendation is meaningless, because only the originally-asked question can possibly get the googlejuice? Yeah, no. Commented Feb 25, 2017 at 21:00
  • Is not about "google juice" is about offering the best conceivable answer while preventing duplicates. Look at this case. All the questions are Y: "I'm trying to do Y, but it fails". How Y fails is not obvious, yet it seems there's no stop to the stream of questions. How do you feel instead someone asks "How to do X The Right Way?"? It prevents all the scattered Y question, so experts has more time to answer more questions, instead of closing/answering the same yet not the same drivel. How wonderful, isn't it? One canonical to rule them all?
    – Braiam
    Commented Feb 25, 2017 at 21:37
  • @Braiam: I feel like you're missing the obvious point here. My recommendation is to create exactly such a potential canonical. Just... in a new question! The only possible problem with this is the idea that such a post could never begin to catch up with the searchability the original question had, and thus the original question must be hijacked in order to take over its search stream. I reject this, and apparently you do too; therefore, there is no possible objection to my proposal! Commented Feb 25, 2017 at 21:45
  • It seems that this comment was lost. The thing is, that the old question doesn't need to exist anymore. It outlived it usefulness for anyone the moment we discovered what we actually want to ask.
    – Braiam
    Commented Feb 1, 2019 at 23:47
8

The XY problem is massively over-invoked on Stack Overflow. Sure, developers suffer from going down rabbit holes from time to time, and you've done exactly that. Now you realise you should have asked something else … so go ahead and ask it.

But there is no reason for your original question to suffer for it. Even if it ends up not being the solution or even the approach you take in your project, it's still a valid question in its own right, with valid answers in their own right. There is nothing to be gained by spoiling that just because you now need to ask something else based on what you've learned in the meantime… so leave the original alone.

There's nothing "magical" about having gone down a rabbit-hole that changes the way you should treat questions and answers on Stack Overflow, no matter how many times "XY problem" is uttered.

Remember, conceptually speaking, the post isn't even for you: it's for the repository.

(Then again, SO is so massively saturated with localised debugging requests nowadays that it's hard to see how it'll ever really get back to its true and pure nature. Sigh. Oh well, back to the bar…)

2
4

I disagree with the accepted answer. Rather, I think it depends.

Often times in XY-problems, you're trying to do something that ends up just being a bad idea on all fronts. It's bad practice, and it doesn't even make any sense. In these cases, the most useful answer to the problem for anyone is to guide them away from even trying what the question asked. So an answer that points out it is an XY-problem and that the practice is bad in general and that potentially provides an alternative direction is absolutely what you want to see on those questions.

Another possibility is that the thing you're trying to do isn't all that bad in and of itself, but it really isn't the best solution for what you want to accomplish. Again, in this case, the best answer is still one that addresses the XY-problem and provides the better alternative.

I suppose there must be some cases where what the question asks makes sense and is completely fine, and in these cases, I would do as @NathanTuggy suggests. However, my experience with questions that end up being XY-problems suggests this is extraordinarily rare, or at the least that it's not identifiable as an XY-problem since there are no red flags to make readers start questioning.

So in the majority of cases, you usually want to steer people finding the question away from what they're trying to do and into something better, and this means an answer that calls out the XY-problem for what it is and gives a superior alternative is preferred.

Not changing questions

There seems to me to be a recent trend toward the notion that we shouldn't change questions if it "invalidates answers." An answer that calls out an XY-problem is still a valid answer to a question about Y, and calling out that the other answers are bad in the process is a good thing. That improves the quality of the content on our site. Our goal is high quality content. Telling users how to implement bad ideas is not high quality content.

4
  • 2
    Even if the desired solution is a bad idea on all fronts, the question itself may act as a signpost to others who are trying to do something similar. In that sense, the question still has value. In most cases, though, an XY question is almost certainly a duplicate, since the very fact that it's being asked demonstrates a lack of research effort and/or a common pitfall for inexperienced developers.
    – JDB
    Commented Oct 22, 2015 at 15:18
  • @JDB Could be. I agree it's a signpost, and part of my point above is that it cannot act as a signpost if the actions in the accepted answer are taken.
    – jpmc26
    Commented Oct 22, 2015 at 16:22
  • @jpmc26: Re: signposting. I've added a further note, but in the case where there's a useful answer stating "here's why this is not a good idea", my advice was already to leave the question there, allowing that answer to continue helping others that run into similar misconceptions. Commented Oct 22, 2015 at 16:48
  • Boy this invokes conflicting feelings in me. One thing that has always gone through all ruling about what is right and wrong on SO has always been to keep in mind what SO is for. And that is a repository of valid questions with valid answers. This seems to lean more towards SO being for valid information regardless of the correctness of the question and the answer. As in the question is "how do I do this and that" and the answers boil down to "you don't want to do that". Is that what SO is for? I'm confused.
    – Gimby
    Commented Oct 23, 2015 at 9:47
-4

Edit the question to ask X.

This! Hundred times! People will search how to do X, not their problem with Y. Making questions about something workable is preferable, since people will tend to have several Y's for a single X. Having a question about X is more useful in the short and long term.

I hate with passion, when I look for the solution to a problem in the form of "How to do X?", instead I'm bombarded about questions about "I have a problem with Y". For me, the X problem is more important to solve and present it to the public that problems with attempted solutions. It's also the mother of all canonical questions! We don't want people asking about problems rolling their own crypto, but how to use the cryptographic tools available for their platform/context correctly.

13
  • I am pretty sure you misunderstood the question. Editing the question as HPierce described would not help to alleviate the problem you've been experiencing at all.
    – Brilliand
    Commented Feb 1, 2019 at 2:12
  • @Brilliand actually, it does meta.stackoverflow.com/q/344546/792066
    – Braiam
    Commented Feb 1, 2019 at 13:34
  • That... has nothing to do with this question. This question is about the XY problem where (for example) someone asks "How do I disable error messages in PHP" (Y) when what he really needs to do is fix the particular error he's seeing (X). The question asked (Y) isn't something vague like "it fails", or something that should never be done, it's just the wrong solution for the asker's actual problem at that time.
    – Brilliand
    Commented Feb 1, 2019 at 22:53
  • Although, I also seem to have a solid disagreement with you on the topic of "rolling your own crypto": you seem to believe that that's always a mistake and there should be no information about it available, but I think the people who write cryptographic libraries are rolling their own crypto, and questions from those people are welcome here. Someone who rolls their own crypto when all they want to do is establish an encrypted connection with someone is doing the wrong thing for their situation, but not doing something that should never be done.
    – Brilliand
    Commented Feb 1, 2019 at 22:59
  • @Brilliand About your last comment, I think I would defer to our friends on InfoSec.SE, which would link you to this question on Crypto.SE. I invite you to expose your position to them, my position is what the people that actually know say. I'm not in any way a security expert, and for that I consult them.
    – Braiam
    Commented Feb 1, 2019 at 23:39
  • Look at the second answer to that question: "There are several senior contributors here that roll their own." You are misrepresenting the people that actually know. You are oversimplifying, and thus giving bad advice that resembles good advice that you heard elsewhere.
    – Brilliand
    Commented Feb 3, 2019 at 12:04
  • @Brilliand "You need to define your threat model before you can conclude what is/is not good enough in regards to security." The threat model by default in any application that is used by third parties is obviously personal information leaking, which is the thread model I use on all questions that wants to roll their own crypto. People doesn't understand that when they write software for others, they need to take into account the compounding threats to all those users. It only needs a single vulnerability to enter the system and exploit it from within.
    – Braiam
    Commented Feb 3, 2019 at 13:13
  • Now @Brilliand, have you seen a "roll your own" crypto that isn't an application used by third parties and not just to hide messages from your grandparents? I'm not misrepresenting anyone, I'm just presuming the worse case scenario unless the question itself purpose it clearly that their code would never be able to allow vulnerabilities to be exploited on others users. "Don't advertise your construction for others to use" is not an understatement.
    – Braiam
    Commented Feb 3, 2019 at 13:14
  • Judging from the wording in this answer, you propose banning all "roll-your-own-crypto" questions, no exceptions. That's different from expecting the worst-case scenario as you read each individual question.
    – Brilliand
    Commented Feb 4, 2019 at 21:02
  • @Brilliand no, I prefer people to ask what their problem they are trying to solve actually is, not the problem with the solution they think they need.
    – Braiam
    Commented Feb 4, 2019 at 21:09
  • A question should only be removed if it isn't a valid question for anyone. It doesn't really matter what the original asker needs.
    – Brilliand
    Commented Feb 4, 2019 at 21:22
  • @Brilliand wait, what? The deletion criteria isn't in discusion here. What is discussed is "I've asked an XY question. What should I do with it?" Read what a XY question is, please.
    – Braiam
    Commented Feb 4, 2019 at 21:38
  • Editing a question into something else entirely is the same as removing it.
    – Brilliand
    Commented Feb 4, 2019 at 21:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .