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

bug report: SpecParser.generate-failed when using OpenAPI specification with 'schema' #12731

Closed
benedikt-udg opened this issue Nov 14, 2024 · 5 comments
Assignees
Labels
investigating needs more info Need user to provide more info no recent activity The issue labeled needs more info gets no reply from issue owner in time TA:Auth Team Area: Auth

Comments

@benedikt-udg
Copy link

benedikt-udg commented Nov 14, 2024

Describe the bug
When trying to add an API plugin using an OpenAI specification that contains a 'schema' element, the import of said specification file fails with the following error:

TypeError: Cannot read properties of undefined (reading 'schema')

stack:
generate-failed: TypeError: Cannot read properties of undefined (reading 'schema')
	at GPr (<REDACTED: user-file-path>/extension.js:483:21444)
	at Hmo (<REDACTED: user-file-path>/extension.js:483:15947)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
	at async Rf.addPlugin (<REDACTED: user-file-path>/extension.js:849:2165)
	at async Rf.ATc (<REDACTED: user-file-path>/extension.js:811:19427)
	at async Rf.<anonymous> (<REDACTED: user-file-path>/extension.js:807:462681)
	at async Rf.ITc (<REDACTED: user-file-path>/extension.js:811:20672)
	at async Rf.<anonymous> (<REDACTED: user-file-path>/extension.js:14:389741)
	at async aw (<REDACTED: user-file-path>/extension.js:1687:18872)
	at async Object.i2a [as callback] (<REDACTED: user-file-path>/extension.js:1709:17263)
	at async e.runCommand (<REDACTED: user-file-path>/extension.js:1687:15449)
	at async Y0.h (file:///c:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:32825)
	at async Y0.h (file:///c:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:32825)

To Reproduce
Steps to reproduce the behavior:

  1. In an existing declarative agent, go to 'Teams Toolkit' in VS Code
  2. Click on 'Add Plugin'
  3. Select 'Start with an OpenAPI Description Document'
  4. Click 'Browse...'
  5. Use a file containing the following OpenAPI specification:
openapi: 3.0.3
info:
  title: Basic Form Submission API
  version: 1.0.0
servers:
  - url: https://api.example.com/v1
paths:
  /submit-form:
    post:
      summary: Submit a form
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: The name of the user
              required:
                - name
      responses:
        '200':
          description: Form submitted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Form submitted successfully!
  1. Select the /submit-form POST method
  2. Select the manifest.json file of the declarative agent
  3. You'll see the following error:
[2024-11-14T12:30:32.057Z] [Error] - code:SpecParser.generate-failed, message: TypeError: Cannot read properties of undefined (reading 'schema')

Expected behavior
The API plugin code should be generated without error.

VS Code Extension Information (please complete the following information):

  • OS: Windows 10
  • Version Teams Toolkit: v5.10.0
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Nov 14, 2024
@adashen adashen added investigating TA:Auth Team Area: Auth labels Nov 19, 2024
@SLdragon
Copy link
Contributor

SLdragon commented Nov 21, 2024

Hi, @benedikt-udg , thanks for your feedback, this is a bug and have already been fixed in dev branch, and will be publish in next release.

For quick workaround, you can update your spec as below, and then revert changes after successful scaffolding:

application/x-www-form-urlencoded -> application/json

openapi: 3.0.3
info:
  title: Basic Form Submission API
  version: 1.0.0
servers:
  - url: https://api.example.com/v1
paths:
  /submit-form:
    post:
      summary: Submit a form
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: The name of the user
              required:
                - name
      responses:
        '200':
          description: Form submitted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Form submitted successfully!

@adashen adashen added needs more info Need user to provide more info and removed needs attention This issue needs the attention of a contributor. labels Nov 21, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the no recent activity The issue labeled needs more info gets no reply from issue owner in time label Nov 29, 2024
@benedikt-udg
Copy link
Author

I can confirm that this workaround works. However, from the first look of it, after I deploy Copilot won't call the API plugin if it has application/x-www-form-urlencoded as a content type. But atm. I cannot investigate further due to the issue mentioned in #12781.

@microsoft-github-policy-service microsoft-github-policy-service bot added needs attention This issue needs the attention of a contributor. and removed no recent activity The issue labeled needs more info gets no reply from issue owner in time needs more info Need user to provide more info labels Nov 29, 2024
@SLdragon
Copy link
Contributor

SLdragon commented Dec 2, 2024

Hi @benedikt-udg, thanks for the information. Could you please check if the API parameters are being called correctly from your backend?

@adashen adashen added needs more info Need user to provide more info and removed needs attention This issue needs the attention of a contributor. labels Dec 2, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@microsoft-github-policy-service microsoft-github-policy-service bot added the no recent activity The issue labeled needs more info gets no reply from issue owner in time label Dec 10, 2024
Copy link
Contributor

Due to lack of details for further investigation, we will archive the issue for now. In case you still have following-up questions on this issue, please always feel free to reopen the issue by clicking ‘reopen issue’ button below the comment box. We will get back to you as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating needs more info Need user to provide more info no recent activity The issue labeled needs more info gets no reply from issue owner in time TA:Auth Team Area: Auth
Projects
None yet
Development

No branches or pull requests

3 participants