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

openapi3 not working when running via ssh connected server #532

Open
t-kitamura-axel opened this issue Jun 9, 2023 · 20 comments
Open

openapi3 not working when running via ssh connected server #532

t-kitamura-axel opened this issue Jun 9, 2023 · 20 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@t-kitamura-axel
Copy link

I can run in testing api based openapi3 sechme in local pc.(openapi server is local docker container)
But, not working when running via ssh connected server.(openapi server is aws container)
bellow err log and runn book

  • runn book
desc: openapi3 test in jump server
runners:
  sc:
    host:  xx-xx-xx
    keepSession: true
    localForward: '10443:xxxx-xxxx.execute-api.xxxxxx.vpce.amazonaws.com:443'
  req:
    endpoint: https://127.0.0.1:10443/xxxx
    openapi3: ../../../openapi3.yaml
    skipVerify: true
debug: true
steps:
  openapi_test:
    desc: Create mission input
    req:
      /xxx/xxx/xx/xxxx_xxx/xxxx:
        get:
          headers:
            accept: application/json
            Content-Type: application/json
            Host: xxxxxxxx
            X-API-KEY: xxxxxxx
    test: steps.openapi_test.res.status == 200

  • err log
  Failure/Error: http request failed on 'openapi3 test in jump server'.steps.openapi_test: no matching operation was found
@k1LoW
Copy link
Owner

k1LoW commented Jun 9, 2023

not working when running via ssh connected server

To identify the cause,
First,
Check if a direct HTTP request is not the problem.

From the error message (no matching operation was found), it seems that the request or response does not conform to the OpenAPI Spec.

@k1LoW k1LoW added the help wanted Extra attention is needed label Jun 9, 2023
@t-kitamura-axel
Copy link
Author

t-kitamura-axel commented Jun 9, 2023

Check if a direct HTTP request is not the problem.

Curl commad request check is success.
Also, when I comment out openapi3: ../../../openapi3.yaml in local and via sshed server , test success.
On the other hand, I think importance, when I not comment out openapi3: ../../../openapi3.yaml in local , test bellow normal err.

Failure/Error: http request failed on 'openapi test in local '.steps.openapi-test: openapi3 validation error: response body doesn't match schema #/components/schemas/xxxxxxxResponse: value must be an object

Why, only the test via ssh is displayed like bellow.

 Failure/Error: http request failed on 'openapi3 test in jump server'.steps.openapi_test: no matching operation was found

This difference is why I think that test via ssh don't read openapi.yaml or not working.
What would you think?

@k1LoW
Copy link
Owner

k1LoW commented Jun 9, 2023

Curl commad request check is success.

To identify the cause,
First,
Check if a direct HTTP request is not the problem.

Try it with runn. cURL does not have the feature to check OpenAPI Spec.

@k1LoW
Copy link
Owner

k1LoW commented Jun 9, 2023

This difference is why I think that test via ssh don't read openapi.yaml or not working.

At this time, we do not know if the problem is via SSH or OpenAPI functionality, as we have little information and cannot reproduce it at hand.

@k1LoW k1LoW added the bug Something isn't working label Jun 9, 2023
@t-kitamura-axel
Copy link
Author

t-kitamura-axel commented Jun 9, 2023

Curl commad request check is success.

To identify the cause,
First,
Check if a direct HTTP request is not the problem.

Try it with runn. cURL does not have the feature to check OpenAPI Spec.

When I execute runn with comment out openapi3: ../../../openapi3.yaml , I have no check err.
For instance bellow.

  • runn book yaml
desc: openapi3 test in jump server
runners:
  sc:
    host:  xx-xx-xx
    keepSession: true
    localForward: '10443:xxxx-xxxx.execute-api.xxxxxx.vpce.amazonaws.com:443'
  req:
    endpoint: https://127.0.0.1:10443/xxxx
    # openapi3: ../../../openapi3.yaml
    skipVerify: true
debug: true
steps:
  openapi_test:
    desc: xxxx xxxx xxxx
    req:
      /xxx/xxx/xx/xxxx_xxx/xxxx:
        get:
          headers:
            accept: application/json
            Content-Type: application/json
            Host: xxxxxxxx
            X-API-KEY: xxxxxxx
    test: steps.openapi_test.res.status == 200

When no comment out openapi3: ../../../openapi3.yaml , I have bellow err.

  • err log
 Failure/Error: http request failed on 'openapi3 test in jump server'.steps.openapi_test: no matching operation was found

@t-kitamura-axel
Copy link
Author

t-kitamura-axel commented Jun 9, 2023

On the other hand, in local, (openapi server launch in local)

when comment out openapi3: ../../../openapi3.yaml , I have no check err.
For instance bellow.

  • local runn book yaml

desc: openapi3 test in local
runners:
  req:
    endpoint: http://localhost:3000
    # openapi3: ../../../openapi3.yaml
debug: true
steps:
  openapi_test:
    desc: xxxx xxxx xxxx
    req:
      /xxx/xxx/xx/xxxx_xxx/xxxx:
        get:
          headers:
            accept: application/json
    test: steps.openapi_test.res.status == 200

When no comment out openapi3: ../../../openapi3.yaml , I have bellow err.

  • err log
Failure/Error: http request failed on 'openapi test in local '.steps.openapi-test: openapi3 validation error: response body doesn't match schema #/components/schemas/xxxxxxxResponse: value must be an object

In local, I have openapi3 validation error: response body doesn't match scheme error.
Via jump server, I have no matching operation was found.
I think local err message normal, but jump server err message illegular, becuase of resuponse is imperfect for no my implementing response(for now, open api generator default return value do some magic!)
So, err contents must be scheme varidation err when test via jump server.

@t-kitamura-axel
Copy link
Author

Thank you for new release. I grad to appreciate your support.
However, this issue cannot be closed.
Still I encounter this probrem

@k1LoW
Copy link
Owner

k1LoW commented Jun 11, 2023

I'm afraid I can't reproduce the error you're seeing.

desc: Test port forwarding with OpenAPI Spec v3
runners:
sc:
host: ${TEST_HOST}
sshConfig: ../sshd/ssh_config
port: ${TEST_PORT}
localForward: '32355:httpbin.org:80'
useAgent: false
req:
endpoint: http://127.0.0.1:32355
openapi3: https://tryapisproxy.com/spec/httpbin
steps:
-
req:
/get:
get:
headers:
Host: httpbin.org
body: null
test: |
current.res.status == 200

no matching operation was found

Are the requests and responses as you intended at this time? Is it the same as for local?

@k1LoW
Copy link
Owner

k1LoW commented Jun 11, 2023

I made the error message friendly in v0.75.2. What errors do you get now? Are the HTTP requests ( method, path ) as you intended?

@t-kitamura-axel
Copy link
Author

Thank you for debug release.
bellow err log.

  • local errr message(nomarl)
 Failure/Error: include failed on 'xxx xxx xxx'.steps.xxx_xxx_Xxx: failed to run xxx/xxx/xxx/xxx/local/yamls/200/normal.yaml: http request failed on 'xxxx xxx xx xxx'.steps.normal: openapi3 validation error: response body doesn't match schema #/xxx/xxxxx/xxxxxResponse: value must be an object
  Schema:
    {
       ${{ response json }}
    }

  Value:
    "do some magic!"

  -----START HTTP REQUEST-----
  GET /xx/xx/xx/xxx/xxx HTTP/1.1
  Host: localhost:3000
  Accept: application/json


  -----END HTTP REQUEST-----
  -----START HTTP RESPONSE-----
  HTTP/1.1 200 OK
  Connection: close
  Content-Length: 17
  Content-Type: application/json
  Date: Sun, 11 Jun 2023 07:42:03 GMT
  Server: Werkzeug/2.2.3 Python/3.10.5

  "do some magic!"

  -----END HTTP RESPONSE-----

1 scenario, 0 skipped, 1 failure
  • via jump sever err log (illegular)

Failure/Error: include failed on 'xxx xxx xx test'.steps.xxx_xxx_xxx: failed to run xxx/xxx/xxx/aws/200/normal.yaml: http request failed on 'xx xx xxxx'.steps.normal: failed to find route: no matching operation was found (GET xxx/xxxx/xxxx)



@k1LoW
Copy link
Owner

k1LoW commented Jun 11, 2023

GET /xx/xx/xx/xxx/xxx HTTP/1.1

1.GET /xx/xx/xx/xxx/xxx

no matching operation was found (GET xxx/xxxx/xxxx)

2.GET xxx/xxxx/xxxx

Can we assume that there is no difference between these two values?

@k2tzumi
Copy link
Collaborator

k2tzumi commented Jun 11, 2023

@t-kitamura-axel

Hi!

I felt that the following response seems to me to be an incorrect definition of openAPI.

  -----START HTTP RESPONSE-----
  HTTP/1.1 200 OK
  Connection: close
  Content-Length: 17
  Content-Type: application/json
  Date: Sun, 11 Jun 2023 07:42:03 GMT
  Server: Werkzeug/2.2.3 Python/3.10.5

  "do some magic!"

  -----END HTTP RESPONSE-----

I think the Content-Type is text/plain, not application/json

I think that is why you are getting the following error

openapi3 validation error: response body doesn't match schema #/xxx/xxxxx/xxxxxResponse: value must be an object

@t-kitamura-axel
Copy link
Author

I change application/json with text/plain.
But, no difference.

@t-kitamura-axel
Copy link
Author

GET /xx/xx/xx/xxx/xxx HTTP/1.1

1.GET /xx/xx/xx/xxx/xxx

no matching operation was found (GET xxx/xxxx/xxxx)

2.GET xxx/xxxx/xxxx

Can we assume that there is no difference between these two values?

I see, no difference.
Just a typo.

@k2tzumi
Copy link
Collaborator

k2tzumi commented Jun 11, 2023

I change application/json with text/plain.

Along with the API implementation, the definition of openapi3.yaml itself needs to be modified.

If the openapi3.yaml has been modified, the error messages in the debug output should change.

@t-kitamura-axel
Copy link
Author

What do you mean?

One of the things I'm having issues with is that the local output and the output over ssh are different.

@t-kitamura-axel
Copy link
Author

t-kitamura-axel commented Jun 11, 2023

Or when ssh port forwarding, should open api yaml's server section be replaced?

@k2tzumi
Copy link
Collaborator

k2tzumi commented Jun 11, 2023

One of the things I'm having issues with is that the local output and the output over ssh are different.

Are both environments in which you are running the runn command local?

Or when ssh port forwarding, should open api yaml's server section be replaced?

It is assumed that the program is running locally, but instead of having it port forwarding, it changes the endpoint specification.

  req:
    endpoint: ${APP_URL:-https://127.0.0.1}/xxxx
    openapi3: ../../../openapi3.yaml

It can be switched by env as above.

$ APP_URL= https://xxxxxx.amazonaws.com runn run path/to.yaml

@k1LoW
Copy link
Owner

k1LoW commented Jun 11, 2023

but instead of having it port forwarding, it changes the endpoint specification.

It looks like he wants to execute HTTP requests via SSH port forwarding.

@k1LoW
Copy link
Owner

k1LoW commented Jun 11, 2023

His environment seems to be as follows.

graph LR
    Local[Local] -- can SSH --o xx-xx-xx[xx-xx-xx]
    xx-xx-xx -- can do HTTP requests --o xxxx-xxxx.execute-api.xxxxxx.vpce.amazonaws.com[xxxx-xxxx.execute-api.xxxxxx.vpce.amazonaws.com]
    Local[Local] -- can NOT do HTTP requests  --x xxxx-xxxx.execute-api.xxxxxx.vpce.amazonaws.com[xxxx-xxxx.execute-api.xxxxxx.vpce.amazonaws.com]
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants