Can a moderator move this to Discussions? It's not a bug.
The only possible scenario where you would lose layers, is if you opened the file through Lightroom. Lightroom doesn't support layers and will always open the flattened composite, even if the original PSD has layers.
Other than that, you have accidentally flattened the file at some point. If you then close the file, the layers are gone permanently and there's no way to get them back.