Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

What causes a400 error with messageServer not found for <url>?#757

Answeredbyp1c2u
jtherrmann asked this question inQ&A
Discussion options

All of the API endpoints for the test deployment of our Flask app, which is deployed via Amazon API Gateway, are currently returning a response like the one below:

{  "detail": "Server not found for https://vd2gh6uqw3.execute-api.us-west-2.amazonaws.com/api/user",  "status": 400,  "title": "Bad Request",  "type": "about:blank"}

We depend on the latest pre-release ofopenapi-core,https://github.com/python-openapi/openapi-core/releases/tag/0.19.0a1.

The error message leads me to believe thatopenapi-core is raising aServerNotFound exception fromBasePathFinder.find (here), which is called fromBaseAPICallValidator._find_path (here).

I have a couple of questions:

  • IsBaseAPICallValidator for validating requests, responses, or both?
  • Why does the validator need to validate the server URL? What exactly doesAPICallPathFinder._get_servers_iter do? What is the fundamental meaning of aServerNotFound exception?
You must be logged in to vote
Answered by p1c2uJan 11, 2024

HI@jtherrmann

the error "Server not found forhttps://vd2gh6uqw3.execute-api.us-west-2.amazonaws.com/api/user" means your OpenAPI specification doesn't define server that match url from your request.

Is BaseAPICallValidator for validating requests, responses, or both?

It's a base class for request and response validation

Why does the validator need to validate the server URL?

Server is part of OpneAPI specification

What exactly doesAPICallPathFinder._get_servers_iter do?

Finds valid server definition in your specification

What is the fundamental meaning of a ServerNotFound exception?

ServerNotFound exception is raised when your request server does not match any defined servers i…

Replies: 1 comment 4 replies

Comment options

HI@jtherrmann

the error "Server not found forhttps://vd2gh6uqw3.execute-api.us-west-2.amazonaws.com/api/user" means your OpenAPI specification doesn't define server that match url from your request.

Is BaseAPICallValidator for validating requests, responses, or both?

It's a base class for request and response validation

Why does the validator need to validate the server URL?

Server is part of OpneAPI specification

What exactly doesAPICallPathFinder._get_servers_iter do?

Finds valid server definition in your specification

What is the fundamental meaning of a ServerNotFound exception?

ServerNotFound exception is raised when your request server does not match any defined servers in your specification.

You must be logged in to vote
4 replies
@jtherrmann
Comment options

@p1c2u This answer was extremely helpful, thank you! I had posted some comments with additional questions, but I deleted them because they were based on a partial misunderstanding of how OpenAPI works. But I understand how server URLs work now and we were able to resolve the issues with our app. Thanks again for your quick response!

@jtherrmann
Comment options

In case anyone reading this is having a similar issue, our problem was that we have an AWS CloudFront distribution that forwards API requests to our AWS ApiGateway app. The forwarded requests have a URL like<api-gateway-url>/api/<endpoint>, e.g.https://vd2gh6uqw3.execute-api.us-west-2.amazonaws.com/api/user, but our app does not expect the/api component. Fixing this issue is as simple as specifying the following relative server URLs in our OpenAPI spec:

servers:  - url: /  - url: /api

The/ url is technically optional, but including it allows us to make queries via our Swagger UI (which would force us to send requests to/api if that were the only server url specified).

@p1c2u
Comment options

I'm glad you found the problem. Any suggestions about debugging improvements are welcome.

@jtherrmann
Comment options

@p1c2u I think the error message for theServerNotFound exception could be improved. When I first saw the error:

Server not found for https://vd2gh6uqw3.execute-api.us-west-2.amazonaws.com/api/user

I assumed that the request had failed to reach the server. I did not even realize that the error was coming from the OpenAPI spec validator. At a minimum, I think the error message should make it clear that this is an OpenAPI spec validation problem. For example, it could say something like this:

Request is not valid for the given OpenAPI spec: Request URL https://vd2gh6uqw3.execute-api.us-west-2.amazonaws.com/api/user does not match any of the OpenAPI spec server URLs

In fact, I think that all request validation errors should begin with something likeRequest is not valid for the given OpenAPI spec: to make it clear that this is an OpenAPI spec error.

Answer selected byjtherrmann
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@jtherrmann@p1c2u

[8]ページ先頭

©2009-2025 Movatter.jp