Write unit test to reproduce.
Manual testing with this sample program it turned out that loose objects can be located, but not objects that are packed.
Here is how it can be invoked:
git rev-list --objects --no-object-names HEAD | cargo eval ./object-access.rs
I recommend installing cargo-eval using cargo install --git https://github.com/reitermarkus/cargo-eval to get the latest greatest.