diff --git a/internal/ostree/ostree.go b/internal/ostree/ostree.go index 0d08a400d..9c14f3f5b 100644 --- a/internal/ostree/ostree.go +++ b/internal/ostree/ostree.go @@ -61,7 +61,7 @@ func ResolveParams(params OSTreeRequest, imageType distro.ImageType) (OSTreeRequ if resolved.Ref == "" { resolved.Ref = imageType.OSTreeRef() } else if !VerifyRef(params.Ref) { // only verify if specified in params - return resolved, fmt.Errorf("Invalid ostree ref") + return resolved, fmt.Errorf("Invalid ostree ref %q", params.Ref) } resolved.URL = params.URL diff --git a/internal/weldr/api_test.go b/internal/weldr/api_test.go index fb13de56d..f7a706e17 100644 --- a/internal/weldr/api_test.go +++ b/internal/weldr/api_test.go @@ -821,7 +821,7 @@ func TestCompose(t *testing.T) { // Ref + invalid URL = error {false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"","url":"invalid-url"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeOptionsError","msg":"Get \"invalid-url/refs/heads/refid\": unsupported protocol scheme \"\""}]}`, nil, []string{"build_id"}}, // Bad Ref + URL = error - {false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"/bad/ref","parent":"","url":"http://ostree/"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeOptionsError","msg":"Invalid ostree ref"}]}`, expectedComposeOSTreeURL, []string{"build_id"}}, + {false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"/bad/ref","parent":"","url":"http://ostree/"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeOptionsError","msg":"Invalid ostree ref \"/bad/ref\""}]}`, expectedComposeOSTreeURL, []string{"build_id"}}, // Ref + Parent + URL = error {false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"parentid","url":"http://ostree/"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeOptionsError","msg":"Supply at most one of Parent and URL"}]}`, expectedComposeOSTreeRef, []string{"build_id"}}, // Parent + URL = error