Skip to content

Attempt to create OpenAPI document only if rest is enabled#1872

Merged
Aniruddh25 merged 4 commits intomainfrom
fixOpenApi
Nov 10, 2023
Merged

Attempt to create OpenAPI document only if rest is enabled#1872
Aniruddh25 merged 4 commits intomainfrom
fixOpenApi

Conversation

@Aniruddh25
Copy link
Copy Markdown
Collaborator

Why make this change?

  • OpenAPI document is needed only when rest is enabled. For cosmosdb_nosql it is never enabled. So, any attempts to create the document will always fail. This shows up as a failure in the logs and has the potential to misguide the actual error that could cause a failure to start the engine.
  • E.g. see below logs from a
    question on stackoverflow

[dataApi] fail: Azure.DataApiBuilder.Service.Startup[0]
[dataApi] OpenAPI Documentor initialization failed.
[dataApi] Azure.DataApiBuilder.Service.Exceptions.DataApiBuilderException: OpenAPI description document can't be created when the REST endpoint is disabled globally.
[dataApi] at Azure.DataApiBuilder.Core.Services.OpenApiDocumentor.CreateDocument() in //src/Core/Services/OpenAPI/OpenApiDocumentor.cs:line 108
[dataApi] at Azure.DataApiBuilder.Service.Startup.PerformOnConfigChangeAsync(IApplicationBuilder app) in /
/src/Service/Startup.cs:line 687
[dataApi] Unable to launch the runtime due to an error.
[dataApi] Error: Failed to start the engine.
[dataApi] cd "C:\Users\alexa\source\repos\az-lead\swa-db-connections" && "C:\Users\alexa.swa\dataApiBuilder\0.9.6-rc\Microsoft.DataApiBuilder.exe" start -c staticwebapp.database.config.json --no-https-redirect exited with code 0

  • On the surface the above error seems to be due to an OpenApi document creation failure, but it shouldn't be the case. We still need more customer logs to understand the issue. This PR is to fix the misguided logs.

What is this change?

  • Gaurd OpenAPI document creation call with a check for REST is enabled or not.
  • Change the log error to log warning - to avoid misguiding.

How was this tested?

  • Started the engine locally to verify after the change the failure is gone for CosmosDb_NoSql.

Sample Request(s)

Before when the engine has successfully started for CosmosDB_NoSql:
image

After:
image

@Aniruddh25
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@Aniruddh25
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@Aniruddh25 Aniruddh25 added this to the 0.9 milestone Nov 9, 2023
@aaronburtle
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@Aniruddh25
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@ayush3797
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@Aniruddh25 Aniruddh25 enabled auto-merge (squash) November 9, 2023 19:52
Copy link
Copy Markdown
Contributor

@seantleonard seantleonard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for updating.

@Aniruddh25
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@Aniruddh25 Aniruddh25 merged commit 7460003 into main Nov 10, 2023
@Aniruddh25 Aniruddh25 deleted the fixOpenApi branch November 10, 2023 00:40
@Aniruddh25 Aniruddh25 added the port needed Describes if port to release branch is required label Nov 13, 2023
Aniruddh25 added a commit that referenced this pull request Nov 13, 2023
## Why make this change?

- OpenAPI document is needed only when rest is enabled. For
cosmosdb_nosql it is never enabled. So, any attempts to create the
document will always fail. This shows up as a failure in the logs and
has the potential to misguide the actual error that could cause a
failure to start the engine.
- E.g. see below logs from a
[question on
stackoverflow](https://stackoverflow.com/questions/77432995/dataapibuilderexception-while-trying-to-run-swa-start)
> [dataApi] fail: Azure.DataApiBuilder.Service.Startup[0]
> [dataApi]       OpenAPI Documentor initialization failed.
> [dataApi]
Azure.DataApiBuilder.Service.Exceptions.DataApiBuilderException: OpenAPI
description document can't be created when the REST endpoint is disabled
globally.
> [dataApi] at
Azure.DataApiBuilder.Core.Services.OpenApiDocumentor.CreateDocument() in
/_/src/Core/Services/OpenAPI/OpenApiDocumentor.cs:line 108
> [dataApi] at
Azure.DataApiBuilder.Service.Startup.PerformOnConfigChangeAsync(IApplicationBuilder
app) in /_/src/Service/Startup.cs:line 687
> [dataApi] Unable to launch the runtime due to an error.
> [dataApi] Error: Failed to start the engine.
> [dataApi] cd "C:\Users\alexa\source\repos\az-lead\swa-db-connections"
&&
"C:\Users\alexa\.swa\dataApiBuilder\0.9.6-rc\Microsoft.DataApiBuilder.exe"
start -c staticwebapp.database.config.json --no-https-redirect exited
with code 0

- On the surface the above error seems to be due to an OpenApi document
creation failure, but it shouldn't be the case. We still need more
customer logs to understand the issue. This PR is to fix the misguided
logs.

## What is this change?

- Gaurd OpenAPI document creation call with a check for REST is enabled
or not.
- Change the log error to log warning - to avoid misguiding.

## How was this tested?

- Started the engine locally to verify after the change the failure is
gone for CosmosDb_NoSql.

## Sample Request(s)

Before when the engine has successfully started for CosmosDB_NoSql:

![image](https://github.com/Azure/data-api-builder/assets/3513779/9f0f7a59-3c07-4f9c-b002-900fcf6e8bc5)

After:

![image](https://github.com/Azure/data-api-builder/assets/3513779/b54dafca-f7aa-4bd4-a4f2-0a88321d0959)

---------

Co-authored-by: Abhishek  Kumar <[email protected]>
Aniruddh25 added a commit that referenced this pull request Nov 13, 2023
## Why make this change?

This is simply cherry-picking the following PRs before creating the next
stable 0.9 version:

- #1876
- #1821 
- #1854 
- #1851 
- #1872 
- #1868

---------

Co-authored-by: Sean Leonard <[email protected]>
Co-authored-by: Abhishek  Kumar <[email protected]>
Co-authored-by: neeraj-sharma2592 <[email protected]>
Co-authored-by: Neeraj Sharma (from Dev Box) <[email protected]>
Co-authored-by: aaronburtle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

port needed Describes if port to release branch is required

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants