question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pushing a non existent tag doesn't raise an exception

See original GitHub issue

I get this error in the error output but no exception is raised:

{"status":"The push refers to repository [485757098324.dkr.ecr.us-east-1.amazonaws.com/ssh_proxy]"}
{"errorDetail":{"message":"An image does not exist locally with the tag: 485757098324.dkr.ecr.us-east-1.amazonaws.com/ssh_proxy"},"error":"An image does not exist locally with the tag: 485757098324.dkr.ecr.us-east-1.amazonaws.com/ssh_proxy"}

Unlike related issue #1772 there’s really no excuse here, since this error can be detected even if trying to push to a black box, while #1772 requires understanding the output of a repo server.

Also worth mentioning that the docker push command WILL return an error code in this case. So actually the docker push command gives MORE info than the SDK function. Since the docker push command gives output + error code. While the SDK function only gives output 😦

(Not saying the function needs to BC break and return two values, just that it needs to raise exceptions when appropriate)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
thaJeztahcommented, Jan 31, 2019

@chris-crone https://github.com/moby/moby/pull/38467 likely won’t help in this case, because the daemon sent a 200 status before it detects the error; https://github.com/moby/moby/pull/38467 will make the client return the status code (instead of just a plain error).

I can try if waiting to send the “The push refers to repository” message until after the initial error detection was done could allow us to send a proper status code (and prevent the 200 status from being sent before that).

FWIW, I do think we still need the python sdk to detect errors if an errorDetail arrives; even though this initial error check could make it possible to send a 4xx status code, there may be situations where an error occurs further down the push (e.g. push is in progress, but the registry returns a failure). Due to this endpoint returning a stream, the status code cannot be updated at that point.

Also, as far as this specific error is concerned, the Docker Engine really should do some trivial validation and detect if a tag doesn’t exist locally and send a 4xx HTTP response rather than attempt a push anyway.

Also see the above; in this case it looks like the validation is actually done before the actual push happens (but the initial message was already sent; I’ll try and see if that particular case can be resolved)

0reactions
milascommented, Dec 16, 2022

@caeus There is no update on this behavior in docker-py. Currently, the library exposes the Engine API as-is here. The engine will return a 200 if the push is able to start, and then streams push status back in the response. If an error is hit during push, that will be reflected in the events. The push_wrapper example from this comment shows how to handle this API response.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you fix a docker push error, tag does not exist?
I misspelled the tag, so when I tried to push with the correct tag name, it couldn't find it (because it didn't exist...
Read more >
Google Tag Manager Errors - Tag Assistant Help
The Data Layer variable name is case-sensitive. If you try to push a variable or event without the proper casing, the push will...
Read more >
A Definitive Guide to Handling Errors in JavaScript - Kinsta
This error occurs when you try to invoke a method that doesn't exist in your script, or it does but can not be...
Read more >
Python KeyError Exceptions and How to Handle Them
In this tutorial, you'll learn how to handle Python KeyError exceptions. They are often caused by a bad key lookup in a dictionary,...
Read more >
Exception and Error Handling in Python - DataCamp
Raise exceptions in Python and catch your errors today! ... ImportError is raised when you try to import a module that does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found