You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When I execute an oras push, the scope that calls the get service token loses the push, only the pull #1599
when i exec oras push xxx/xxx/test:v1 test.txt ,then i got a fail msg . but i add the --debug flag ,like oras push xxx/xxx/test:v1 test.txt --debug. it push successfully.
this problem dose not apper in normal registry,like harbor,docker hub
i catch access log find that when i exec cmd oras push xxx/xxx/test:v1 test.txt, the url of calling get service token like this https://127.0.0.1/service/token?service=hg-registry&scope=repository%3Ahg-ns1%2Ftest%3Apull and when i exec cmd oras push xxx/xxx/test:v1 test.txt --debug,the url is https://127.0.0.1/service/token?service=hg-registry&scope=repository%3Ahg-ns1%2Ftest%3Apush%2Cpull
there is something diff between within --debug and without --debug
Does it always succeed with --debug and always fail without?
yes, it always succeed with --debug,and always fail without。the registry is a custom registry base on harbor. we add some validate when client gets service token .
when i push something to a project which the registry is not contain in that project, it will be fail .because there are any valiations in get service token,other client like docker or ctr ,they will add pull and push in scope. but when oras do these,it only add pull
Based on your proposed fix, I would think it would work if you specified --to-tty which is at least a better work-around for you.
did you mean --no-tty,i try add --no-tty,It is indeed effective in correcting the service token URL.Change the URL to the correct https://127.0.0..1/service/token?scope=repository%3Aoras-test%2Foras%3Apull&service=my-registry
Hi @hopegi, could you share a complete debug log of oras push for us to analyze? A run of oras version is also appreciated.
oras version is 1.2.0,1.2.2 also appera this problem.
the problem is that i exec oras push xxxxx --debug or oras push xxxxx --no-tty, then oras will use https://127.0.0..1/service/token?scope=repository%3Aoras-test%2Foras%3Apull%2Cpush&service=my-registry to get the serivce token . the url is correct in this time, but when i remove --debug or --no-tty , the url will be change to https://127.0.0..1/service/token?scope=repository%3Aoras-test%2Foras%3Apull&service=my-registry, which is lease push in scope`s action.
i show you the debug's log,but it is not easy to found the problem of the code i think. to releate the pr, ctx = registryutil.WithScopeHint(ctx, dst, auth.ActionPull, auth.ActionPush) can not set pull and push in to dst,because the dst is not instance of remote.Repository,
Thanks @hopegi for the information. This is indeed a bug. The root cause is that, when tty is used, originDst is wrapped by a status display handler on line 216, and the resulted dst is not a *remote.Repository. As a result, the scope hints cannot be correctly added on line 227. When tty is not used, originDst is not wrapped so the scope hints work as expected.
Activity
TerryHowe commentedon Dec 26, 2024
What is the failure message?
What is the registry?
Does it always succeed with --debug and always fail without?
hopegi commentedon Dec 27, 2024
yes, it always succeed with --debug,and always fail without。the registry is a custom registry base on harbor. we add some validate when client gets service token .
hopegi commentedon Dec 27, 2024
when i push something to a project which the registry is not contain in that project, it will be fail .because there are any valiations in get service token,other client like docker or ctr ,they will add pull and push in scope. but when oras do these,it only add pull
TerryHowe commentedon Dec 27, 2024
Based on your proposed fix, I would think it would work if you specified
--to-ttywhich is at least a better work-around for you.shizhMSFT commentedon Dec 30, 2024
Hi @hopegi, could you share a complete debug log of
oras pushfor us to analyze? A run oforas versionis also appreciated.hopegi commentedon Dec 30, 2024
did you mean
--no-tty,i try add--no-tty,It is indeed effective in correcting the service token URL.Change the URL to the correcthttps://127.0.0..1/service/token?scope=repository%3Aoras-test%2Foras%3Apull&service=my-registryhopegi commentedon Dec 30, 2024
oras version is 1.2.0,1.2.2 also appera this problem.
the problem is that i exec
oras push xxxxx --debugororas push xxxxx --no-tty, then oras will usehttps://127.0.0..1/service/token?scope=repository%3Aoras-test%2Foras%3Apull%2Cpush&service=my-registryto get the serivce token . the url is correct in this time, but when i remove--debugor--no-tty, the url will be change tohttps://127.0.0..1/service/token?scope=repository%3Aoras-test%2Foras%3Apull&service=my-registry, which is lease push in scope`s action.i show you the debug's log,but it is not easy to found the problem of the code i think. to releate the pr,
ctx = registryutil.WithScopeHint(ctx, dst, auth.ActionPull, auth.ActionPush)can not set pull and push in todst,because thedstis not instance ofremote.Repository,Wwwsylvia commentedon Jan 3, 2025
Thanks @hopegi for the information. This is indeed a bug. The root cause is that, when tty is used,
originDstis wrapped by a status display handler on line 216, and the resulteddstis not a*remote.Repository. As a result, the scope hints cannot be correctly added on line 227. When tty is not used,originDstis not wrapped so the scope hints work as expected.oras/cmd/oras/root/push.go
Lines 211 to 235 in 677529b
oras/internal/registryutil/auth.go
Lines 25 to 31 in 677529b
The same issue exists in the main branch too.
Wwwsylvia commentedon Jan 3, 2025
One possible fix could be to pass the repo reference to
auth.AppendRepositoryScope, avoiding casting the wrapped target to*remote.Repository?docs: update 1.2 docs for ORAS CLI v1.2.3 (#687)