From 6d6c11dcebbdaa40b009f4416d41e3d4abad998f Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 23 Dec 2016 22:57:30 -0800 Subject: [PATCH] Fix inspect object by invalid reference Signed-off-by: Tonis Tiigi (cherry picked from commit 3cd39aaeab37102e4b12decc0c36042e477e2fa6) Signed-off-by: Victor Vieux --- integration-cli/docker_cli_inspect_test.go | 8 ++++++++ plugin/store.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/integration-cli/docker_cli_inspect_test.go b/integration-cli/docker_cli_inspect_test.go index 4e732c5ba8..32ed28afe1 100644 --- a/integration-cli/docker_cli_inspect_test.go +++ b/integration-cli/docker_cli_inspect_test.go @@ -456,3 +456,11 @@ func (s *DockerSuite) TestInspectUnknownObject(c *check.C) { c.Assert(out, checker.Contains, "Error: No such object: foobar") c.Assert(err.Error(), checker.Contains, "Error: No such object: foobar") } + +func (s *DockerSuite) TestInpectInvalidReference(c *check.C) { + // This test should work on both Windows and Linux + out, _, err := dockerCmdWithError("inspect", "FooBar") + c.Assert(err, checker.NotNil) + c.Assert(out, checker.Contains, "Error: No such object: FooBar") + c.Assert(err.Error(), checker.Contains, "Error: No such object: FooBar") +} diff --git a/plugin/store.go b/plugin/store.go index ba0eb03400..bb57e80665 100644 --- a/plugin/store.go +++ b/plugin/store.go @@ -227,7 +227,7 @@ func (ps *Store) resolvePluginID(idOrName string) (string, error) { ref, err := reference.ParseNamed(idOrName) if err != nil { - return "", errors.Wrapf(err, "failed to parse %v", idOrName) + return "", errors.WithStack(ErrNotFound(idOrName)) } if _, ok := ref.(reference.Canonical); ok { logrus.Warnf("canonical references cannot be resolved: %v", ref.String())