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

Error: There are multiple operations defined for 'get: <path>' #4898

Closed
mikeharder opened this issue Mar 2, 2024 · 5 comments
Closed

Error: There are multiple operations defined for 'get: <path>' #4898

mikeharder opened this issue Mar 2, 2024 · 5 comments
Assignees

Comments

@mikeharder
Copy link
Member

Repro Steps

  1. Checkout Azure/azure-rest-api-specs@0817dfd

> npx autorest@3.6.1 --v3 --spectral --azure-validator --semantic-validator=false --model-validator=false
--message-format=json --openapi-type=data-plane --openapi-subtype=data-plane
--use=@microsoft.azure/openapi-validator@2.2.0
--tag=package-2023-04-01 specification/devcenter/data-plane/readme.md

Bugs

This one repro has exposed multiple bugs.

The first exception was:

Exception has occurred: TypeError: Cannot convert undefined or null to object
  at Function.entries (<anonymous>)
    at getMergedProfilesMetadata (/home/mharder/.autorest/@autorest_core@3.10.1/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:16749:39)
    at Deduplicator.deduplicatePaths (/home/mharder/.autorest/@autorest_core@3.10.1/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:16905:40)
    at Deduplicator.init (/home/mharder/.autorest/@autorest_core@3.10.1/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:16828:26)
    at Deduplicator.getOutput (/home/mharder/.autorest/@autorest_core@3.10.1/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:17101:13)
    at deduplicate (/home/mharder/.autorest/@autorest_core@3.10.1/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:2485:76)
    at ScheduleNode (/home/mharder/.autorest/@autorest_core@3.10.1/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:1351:29)

This was fixed in #4896.

However, running the repro after this fix leads to another exception:

Exception has occurred: Error: There are multiple operations defined for 
  'get: /projects/{projectName}/operationstatuses/{operationId}'.

  You are probably trying to use an input with multiple API versions with an autorest V2 generator, and that will not work. 
  at NewComposer.visitPath (/home/mharder/.autorest/@autorest_core@3.10.2/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:4371:23)
    at NewComposer.visitPaths (/home/mharder/.autorest/@autorest_core@3.10.2/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:4357:22)
    at NewComposer.process (/home/mharder/.autorest/@autorest_core@3.10.2/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:4305:26)
    at NewComposer.runProcess (/home/mharder/.autorest/@autorest_core@3.10.2/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:16339:28)
    at NewComposer.getOutput (/home/mharder/.autorest/@autorest_core@3.10.2/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:16259:9)
    at compose (/home/mharder/.autorest/@autorest_core@3.10.2/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:4624:56)
    at ScheduleNode (/home/mharder/.autorest/@autorest_core@3.10.2/node_modules/@autorest/core/dist/src_lib_autorest-core_ts.js:1351:29)
@timotheeguerin
Copy link
Member

This one looks expected to me

@mikeharder
Copy link
Member Author

This one looks expected to me

Are you saying it's expected that autorest fails on duplicate paths, and fix #4896 was just to convert the failure from a crash to a better error message? Or did the spec have multiple issues, and fixing #4896 fixed one issue which just exposed the next issue?

@timotheeguerin
Copy link
Member

timotheeguerin commented Mar 4, 2024

from the place where this error is emitted

         // we're attempting to put another operation at the same path/method
        // where there is one already.
        // This is likely a case where a multi-api-version file is trying to
        // go thru the composer, and this is not allowed.
        throw new Error(
          `There are multiple operations defined for \n  '${key}: ${metadata.path}'.\n\n  You are probably trying to use an input with multiple API versions with an autorest V2 generator, and that will not work. `,
        );

autorest is basically just a pipeline runner. It provides all those plugins where a few are those old legacy one(including this new composer. I have no idea why you still be calling this here.

The duplicate operation is also something I am just confused it would ever work. The only things that I can see autorest was kinda design to work with is if you loaded different version of the same api but that's something we never actually did.
If you pass those spec through the m4 pipeline(generate SDK) it also fails later complaining about some duplication. TO me this just seems like this spec shouldn't be keeping those dup operations.

The previous bug I fixed was bad in the sense that it was just crashing with a meaningless message and that's not something we should do.

@timotheeguerin
Copy link
Member

So digging into that, it might be getting there because of autorest deciding to run the legacy pipeline by default. Maybe we could not do that anymore(though I am worried this will break existing flow) so maybe have a flag.

However my last point still stand. Even though the linter flow might not complain about that it would still fail later.

@mikeharder
Copy link
Member Author

To me this just seems like this spec shouldn't be keeping those dup operations.

I think this was a temporary bug in the spec -- it's since been updated to remove the dup operations.

Closing for now, will re-open if this becomes a recurring problem.

@mikeharder mikeharder reopened this Mar 4, 2024
@mikeharder mikeharder closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants