apiops icon indicating copy to clipboard operation
apiops copied to clipboard

[BUG]Error when removing an operation or attempting to revert an unsuccessful modification

Open ehalas opened this issue 7 months ago • 2 comments

Release version

v6.0.1.4

Describe the bug

When attempting to publish an API by removing operations, an ‘operation not found’ error occurs, breaking the entire publishing process and leaving the API in an inconsistent state.

##[error]System.Net.Http.HttpRequestException: HTTP request to URI [https://***/policies/policy?api-version=2023-09-01-preview](https://%2A%2A%2A/policies/policy?api-version=2023-09-01-preview) failed with status code 404. Content is '{"error":{"code":"ResourceNotFound","message":"Operation not found.","details":null}}'.

Expected behavior

No error should occur, only a warning, upon attempts to remove a non-existent operation or to rollback all preceding operations

Actual behavior

Error when attempting to publish an API by removing operations:

Content is '{"error":{"code":"ResourceNotFound","message":"Operation not found.","details":null}}'.

Reproduction Steps

remove operation xml polices and operations path from specification.json and then publish

ehalas avatar Jun 01 '25 23:06 ehalas

  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.

github-actions[bot] avatar Jun 01 '25 23:06 github-actions[bot]

@waelkdouh and @guythetechie , I can confirm this issue. It appears that when we execute the PUT for the api specification.yaml file it also removes any association with the operation policies. Which means when we go back to remove those operation polices b/c those folders were removed the API returns 404 as they no longer exist in APIM. The extractor handles this but just updating the specification.yaml file and leaves the operation folders alone which works from an APIM perspective and you don't get any errors, but it's a bit odd as you have folders under operations that are no longer in your APIM instance.

Currently the workaround for this would be the following:

  • If running the extractor:
    • Remove the operation(s) in the portal
    • Run the extractor and publisher (shouldn't see any issues as it just updates the specification.yaml file)
  • If editing code directly:
    • Only update the specification.yaml file to remove the operation(s) and run the publisher
  • Finally:
    • Remove the operation folder(s) in your code and either:
      • Don't run the publisher
      • Run the publisher with 'publish-all-artifacts' option

anotherRedbeard avatar Aug 26 '25 19:08 anotherRedbeard