Hi,
Some time ago,the following patch clean up error handling in pg_basebackup's walmethods.c.
https://github.com/postgres/postgres/commit/248c3a9
This patch keep the error state in the DirectoryMethodData struct,
in most functions, the lasterrno is set correctly, but in function dir_existsfile(),
the lasterrno is not set when the file fails to open.
If this is a correction omission, I think this patch can fix this.
Cheers