Azure / apiops

APIOps applies the concepts of GitOps and DevOps to API deployment. By using practices from these two methodologies, APIOps can enable everyone involved in the lifecycle of API design, development, and deployment with self-service and automated tools to ensure the quality of the specifications and APIs that they’re building.
https://azure.github.io/apiops
MIT License
328 stars 193 forks source link

[BUG] API's with revisions are not being set to current. #646

Open automachina opened 2 months ago

automachina commented 2 months ago

Release version

6.0.1.1

Describe the bug

The publishing of our APIM artifacts is failing once there's a reference to an API operation that only exists in the parent APIs second revision, even though the second revision should be the current revision. Looking at the APIs in Azure, I see that the first revision is set as current even though the APIs apiInformation.json file has it's isCurrent property set to true.

From what I can tell, looking at the code, the isCurrent value is being nulled out of the API Dto object to prevent occasional failures.

image

This causes the API to be initially deployed with out the isCurrent property set, defaulting to revision 1 as current.

I then noticed that there's a process in place to "correct" the revision number: CorrectApimRevisionNumber. But, reviewing that code, I think I found a small bug preventing that process from correcting the revision numbers of revisioned APIs.

image

I could be wrong, but it appears that this would skip all revisioned APIs when assessing them for correction.

To test this, I cloned the repo and updated line 369 to:

if (ApiName.IsNotRevisioned(name))

After that, I ran it locally and it published successfully.

Expected behavior

I expect API revisions to be set correctly in accordance to the API's apiInformation.json file.

Actual behavior

Revisioned APIs do not have the correct revision set to current after deployment, causing failures when anything in the now non-current API is referenced.

Reproduction Steps

In a new APIM instance:

  1. Create an API with a single operation.
  2. Revision the API.
  3. Create another operation in that new revision.
  4. Set the second revision as current (Make current).
  5. Extract the APIM instance.
  6. Delete all APIs or create another new APIM instance.
  7. Publish the extracted artifacts to the cleaned or new APIM instance.

You should see that revision 1 is incorrectly set as current.

github-actions[bot] commented 2 months ago
  Thank you for opening this issue! Please be patient while we will look into it and get back to you as this is an open source project. In the meantime make sure you take a look at the [closed issues](https://github.com/Azure/apiops/issues?q=is%3Aissue+is%3Aclosed) in case your question has already been answered. Don't forget to provide any additional information if needed (e.g. scrubbed logs, detailed feature requests,etc.).
  Whenever it's feasible, please don't hesitate to send a Pull Request (PR) our way. We'd greatly appreciate it, and we'll gladly assess and incorporate your changes.
guythetechie commented 2 months ago

@automachina - thanks for raising this. Could be related to #643.

The revision logic is more complicated than I'd like, unfortunately. Spent dozens of hours on it and working around edge cases. I'll test your scenario and report back.

krishnavatsavai commented 1 month ago

Hi Just wanted to check if we have an update on this. We are using revisions and facing this issue.