Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using rhoas CLI to create a Service Registry artifact results in an error. An equivalent curl request succeeds. #1747

Closed
jsenko opened this issue Sep 22, 2022 · 2 comments
Assignees
Labels
bug Something isn't working priority/critical These should be fixed before the next release.

Comments

@jsenko
Copy link
Collaborator

jsenko commented Sep 22, 2022

Description

Version: 0.51.0

Using rhoas CLI to create a Service Registry artifact results in an error. An equivalent curl request succeeds.

Steps to reproduce

Executing the following command (after logging in, selecting a Registry, etc.)

rhoas service-registry artifact create --artifact-id tweets-topic-test-3 --file 2.0-petstore_v1.json --description "hello world"

results in

Using default artifacts group.
Opening file: 2.0-petstore_v1.json
❌ InvalidArtifactTypeException: Failed to discover artifact type from content.. Run the command in verbose mode using the -v flag to see more information

The content of 2.0-petstore_v1.json is https://gist.github.com/rkpattnaik780/a8797a2bfdf3550a76f1a04ee32e9986

Expected vs actual behaviour

Executing an equivalent request using curl

export TOKEN=`rhoas authtoken`
curl -X POST -H "Authorization: Bearer $TOKEN" -H "X-Registry-Artifactid: tweets-topic-test-3" -H "X-Registry-Description: hello world" -H "Content-Type: application/json" -d @2.0-petstore_v1.json https://bu98.serviceregistry.rhcloud.com/t/969b527a-eb77-418b-9965-26cbf7162605/apis/registry/v2/groups/default/artifacts

returns

{"description":"hello world","createdBy":"jsenko_srs","createdOn":"2022-09-22T09:42:20+0000","modifiedBy":"jsenko_srs","modifiedOn":"2022-09-22T09:42:20+0000","id":"tweets-topic-test-3","version":"1","type":"OPENAPI","globalId":1,"state":"ENABLED","contentId":1,"references":[]}

Logs

Verbose logs:

[jsenko work ] $ rhoas service-registry artifact create --artifact-id tweets-topic-test-3 --file 2.0-petstore_v1.json --description "hello world" -v
Checking for updates. Last check was done: 1663838883428
Refreshing tokens
Tokens refreshed
2022/09/22 11:34:02 
GET /api/serviceregistry_mgmt/v1/registries/969b527a-eb77-418b-9965-26cbf7162605 HTTP/1.1
Host: api.openshift.com
User-Agent: rhoas-cli_0.51.0
Accept: application/json
Accept-Encoding: gzip


2022/09/22 11:34:03 
HTTP/1.1 200 OK
Content-Length: 560
Cache-Control: private
Content-Type: application/json
Date: Thu, 22 Sep 2022 09:34:02 GMT
Server: envoy
Set-Cookie: <removed>; path=/; HttpOnly; Secure; SameSite=None
Strict-Transport-Security: max-age=31536000; includeSubdomains
X-Envoy-Upstream-Service-Time: 20

{"id":"969b527a-eb77-418b-9965-26cbf7162605","kind":"ServiceRegistry","href":"/api/serviceregistry_mgmt/v1/registries/969b527a-eb77-418b-9965-26cbf7162605","status":"ready","registryUrl":"https://bu98.serviceregistry.rhcloud.com/t/969b527a-eb77-418b-9965-26cbf7162605","browserUrl":"https://console.redhat.com/application-services/service-registry/t/969b527a-eb77-418b-9965-26cbf7162605","name":"jsenko-prod-test1","registryDeploymentId":1,"owner":"jsenko_srs","created_at":"2022-09-22T09:31:08Z","updated_at":"2022-09-22T09:31:08Z","instance_type":"standard"}
2022/09/22 11:34:03 
GET /api/serviceregistry_mgmt/v1/registries/969b527a-eb77-418b-9965-26cbf7162605 HTTP/1.1
Host: api.openshift.com
User-Agent: rhoas-cli_0.51.0
Accept: application/json
Accept-Encoding: gzip


2022/09/22 11:34:03 
HTTP/1.1 200 OK
Content-Length: 560
Cache-Control: private
Content-Type: application/json
Date: Thu, 22 Sep 2022 09:34:03 GMT
Server: envoy
Set-Cookie: <removed>; path=/; HttpOnly; Secure; SameSite=None
Strict-Transport-Security: max-age=31536000; includeSubdomains
X-Envoy-Upstream-Service-Time: 20

{"id":"969b527a-eb77-418b-9965-26cbf7162605","kind":"ServiceRegistry","href":"/api/serviceregistry_mgmt/v1/registries/969b527a-eb77-418b-9965-26cbf7162605","status":"ready","registryUrl":"https://bu98.serviceregistry.rhcloud.com/t/969b527a-eb77-418b-9965-26cbf7162605","browserUrl":"https://console.redhat.com/application-services/service-registry/t/969b527a-eb77-418b-9965-26cbf7162605","name":"jsenko-prod-test1","registryDeploymentId":1,"owner":"jsenko_srs","created_at":"2022-09-22T09:31:08Z","updated_at":"2022-09-22T09:31:08Z","instance_type":"standard"}
2022/09/22 11:34:03 
GET /api/serviceregistry_mgmt/v1/registries/969b527a-eb77-418b-9965-26cbf7162605 HTTP/1.1
Host: api.openshift.com
User-Agent: rhoas-cli_0.51.0
Accept: application/json
Accept-Encoding: gzip


2022/09/22 11:34:03 
HTTP/1.1 200 OK
Content-Length: 560
Cache-Control: private
Content-Type: application/json
Date: Thu, 22 Sep 2022 09:34:03 GMT
Server: envoy
Set-Cookie: <removed>; path=/; HttpOnly; Secure; SameSite=None
Strict-Transport-Security: max-age=31536000; includeSubdomains
X-Envoy-Upstream-Service-Time: 23

{"id":"969b527a-eb77-418b-9965-26cbf7162605","kind":"ServiceRegistry","href":"/api/serviceregistry_mgmt/v1/registries/969b527a-eb77-418b-9965-26cbf7162605","status":"ready","registryUrl":"https://bu98.serviceregistry.rhcloud.com/t/969b527a-eb77-418b-9965-26cbf7162605","browserUrl":"https://console.redhat.com/application-services/service-registry/t/969b527a-eb77-418b-9965-26cbf7162605","name":"jsenko-prod-test1","registryDeploymentId":1,"owner":"jsenko_srs","created_at":"2022-09-22T09:31:08Z","updated_at":"2022-09-22T09:31:08Z","instance_type":"standard"}
Making request to https://bu98.serviceregistry.rhcloud.com/t/969b527a-eb77-418b-9965-26cbf7162605/apis/registry/v2
Using default artifacts group.
Opening file: 2.0-petstore_v1.json
2022/09/22 11:34:03 
POST /t/969b527a-eb77-418b-9965-26cbf7162605/apis/registry/v2/groups/default/artifacts HTTP/1.1
Host: bu98.serviceregistry.rhcloud.com
User-Agent: rhoas-cli_0.51.0
Content-Length: 3
Accept: application/json
Content-Type: application/json
X-Registry-Artifactid: tweets-topic-test-3
X-Registry-Description: hello world
Accept-Encoding: gzip

{}

POST /t/969b527a-eb77-418b-9965-26cbf7162605/apis/registry/v2/groups/default/artifacts HTTP/1.1
Host: bu98.serviceregistry.rhcloud.com
Accept: application/json
Authorization: Bearer <removed>
Content-Type: application/json
User-Agent: rhoas-cli_0.51.0
X-Registry-Artifactid: tweets-topic-test-3
X-Registry-Description: hello world


HTTP/1.1 400 Bad Request
Content-Length: 203
Content-Type: application/json
Date: Thu, 22 Sep 2022 09:34:03 GMT
Server: envoy
Set-Cookie: <removed>; path=/; HttpOnly; Secure; SameSite=None
X-Envoy-Upstream-Service-Time: 15

{"message":"Failed to discover artifact type from content.","error_code":400,"detail":"InvalidArtifactTypeException: Failed to discover artifact type from content.","name":"InvalidArtifactTypeException"}
2022/09/22 11:34:03 
HTTP/1.1 400 Bad Request
Content-Length: 203
Content-Type: application/json
Date: Thu, 22 Sep 2022 09:34:03 GMT
Server: envoy
Set-Cookie: <removed>; path=/; HttpOnly; Secure; SameSite=None
X-Envoy-Upstream-Service-Time: 15

{"message":"Failed to discover artifact type from content.","error_code":400,"detail":"InvalidArtifactTypeException: Failed to discover artifact type from content.","name":"InvalidArtifactTypeException"}
Sending telemetery information for rhoas service-registry artifact create
❌ InvalidArtifactTypeException: Failed to discover artifact type from content.. Run the command in verbose mode using the -v flag to see more information
@jsenko jsenko added the bug Something isn't working label Sep 22, 2022
@wtrocki wtrocki added priority/critical These should be fixed before the next release. and removed needs-triage labels Sep 22, 2022
@wtrocki wtrocki self-assigned this Sep 22, 2022
@wtrocki
Copy link
Collaborator

wtrocki commented Sep 22, 2022

Workaround for this is to force artifact type flag. Then registry doesn't fail.

@wtrocki
Copy link
Collaborator

wtrocki commented Sep 23, 2022

@wtrocki wtrocki closed this as completed Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority/critical These should be fixed before the next release.
Projects
None yet
Development

No branches or pull requests

3 participants