Assuming that I have a posted a question with working code, and I've discovered a bug in it without the help of an answer, is it okay to edit the code in the post with a fix?


3 Answers 3


That's absolutely okay as there's no intentional answer invalidation involved.

In order to keep out noise with this, you should just make the changes without adding in-post notes about these changes. They should only be in the edit summary.

When doing this, however, be wary that someone may already be in the process of typing an answer that could include a fix for this bug. If this happens and the answerer doesn't take note of your edit before submitting the answer, then you may have to undo your edit.


Two scenarios:

I just posted, and found a bug seconds after.

Leave a comment on your post to that effect (in case anyone is currently in the process of writing an answer), and then ninja-edit the fix into the post. If you do it within the 5-minute grace period, it won't even leave a trace in the revision history.

Then delete the comment, and nobody will even know about it :)

I posted my question a while back, a just now I found a bug.

The question is on-topic because the code was working to the best of your knowledge, at the time you posted it. Reviewers find bugs OP didn't know about, it happens - that's also what Code Review is for after all! Post a selfie answer instead of editing.

If there are already answers, and nobody is mentioning it... the best is still to post a selfie answer.

Try to make your selfie cover a little more than just the bug you found - self-reviewing is hard, but not impossible.


I would think yes it is okay, as long as it doesn't invalidate one of the answers and the post is quite recent.

However, perhaps it would be more beneficial to instead post a selfie answer as Community Wiki explaining how you found the bug and such, that way it brings educational value to the post as a whole.


You must log in to answer this question.

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