Skip to content

Commit 07f3e96

Browse files
committed
If failed to get credential - inform on what input, and use stdout if no stderr output
In my case I was trying with such a minimal usecase import oras.client from oras.container import Container client = oras.client.OrasClient() container = Container("neurodebian:sid") client.get_manifest(container) and I had ❯ docker-credential-secretservice list {"https://index.docker.io/v1/":"repronimservices","workshop.dev.flywheel.io":"yarikoptic@gmail.com"} Running the script resulted in hard to digest and not very informative traceback which started with ❯ uv run try_oras.py Credential helper 'docker-credential-secretservice' failed: NB it then continued with not directly related traceback on JSONDecodeError because was returned HTML I guess instead of json... not clear why continued to start with. Not yet sure how the "input" should be fixed up (but seems need to be a url not just hostname), but this PR fixes at least the error to become informative. With it we get: Credential helper 'docker-credential-secretservice' for 'docker.io' failed: credentials not found in native keychain FTR: ❯ dlocate docker-credential-secretservice golang-docker-credential-helpers: /usr/bin/docker-credential-secretservice ❯ apt-cache policy golang-docker-credential-helpers | cat golang-docker-credential-helpers: Installed: 0.6.4+ds1-1+b18 Candidate: 0.6.4+ds1-1+b18 Version table: *** 0.6.4+ds1-1+b18 900 600 https://deb.debian.org/debian sid/main amd64 Packages 900 https://deb.debian.org/debian forky/main amd64 Packages 100 https://deb.debian.org/debian trixie/main amd64 Packages 100 /var/lib/dpkg/status
1 parent 3c63985 commit 07f3e96

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

oras/auth/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ def _logout(self):
6666

6767
def _get_auth_from_creds_store(self, suffix: str, hostname: str) -> Optional[str]:
6868
binary = f"docker-credential-{suffix}"
69+
stdin = hostname
6970
try:
7071
proc = subprocess.run(
7172
[binary, "get"],
72-
input=hostname.encode(),
73+
input=stdin.encode(),
7374
stdout=subprocess.PIPE,
7475
stderr=subprocess.PIPE,
7576
check=True,
@@ -79,7 +80,8 @@ def _get_auth_from_creds_store(self, suffix: str, hostname: str) -> Optional[str
7980
return None
8081
except subprocess.CalledProcessError as exc:
8182
logger.warning(
82-
f"Credential helper '{binary}' failed: {exc.stderr.decode().strip()}"
83+
f"Credential helper '{binary}' for {stdin!r} failed: "
84+
f"{(exc.stderr or exc.stdout).decode().strip()}"
8385
)
8486
return None
8587
payload = json.loads(proc.stdout)

0 commit comments

Comments
 (0)