OfficeDev / teams-toolkit

Developer tools for building Teams apps
Other
468 stars 193 forks source link

Getting this error : TypeError: Cannot read properties of undefined (reading 'type') because I have an endpoint definition that uses content along with schema #12767

Open midhunloopio opened 1 day ago

midhunloopio commented 1 day ago

Describe the bug I'm getting this error from the specParser when I am trying to build a declarative agent with plugin support based on my openAPI document : code:SpecParser.validate-failed, message: TypeError: Cannot read properties of undefined (reading 'type')

I have figured out what the cause could be :

To Reproduce Steps to reproduce the behavior:

  1. Open Teams toolkit extension in VSCode and click Create a New App and click Agent
  2. Click Declarative agent
  3. Select Add plugin
  4. Select Start with an OpenAPI Description Document
  5. Provide an openAPI document with similar path and schema as below :
    
    openapi: 3.0.1
    info:
    title: example title
    description: example description
    termsOfService: example terms
    contact:
    email: support@example.com
    servers:
    - url:*********
    tags:
    - name: Library Entries
    description: Create and manage Library Entries

components: schemas: LibrarySearchOptions: type: object properties: lastUpdatedDate: $ref: '#/components/schemas/DateTimeRangeFilter' language: type: string example: en locations: type: array items: $ref: '#/components/schemas/LibraryLocation' searchQuery: type: string example: What is Loopio? synonyms: type: boolean example: true description: Allow searching for synonyms of searchQuery terms. exactPhrase: type: boolean example: false description: All searchQuery terms must be present in the given order. hasAttachment: type: boolean example: true description: Search for Entries with one or more Attachments searchInQuestions: type: boolean default: true example: false description: Search within Entry Question text. searchInAnswers: type: boolean default: true example: false description: Search within Entry Answer text. searchInTags: type: boolean default: true example: false description: Search within Entry Tags. example: lastUpdatedDate: gte: '2020-01-01T00:00:00Z' locations:

Expected behavior OpenAPI document must be picked up without any validation errors. Validation error should not happen as I've already validated this yaml file with Swagger

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

microsoft-github-policy-service[bot] commented 1 day ago

Thank you for contacting us! Any issue or feedback from you is quite important to us. We will do our best to fully respond to your issue as soon as possible. Sometimes additional investigations may be needed, we will usually get back to you within 2 days by adding comments to this issue. Please stay tuned.

sayali-MSFT commented 19 hours ago

@midhunloopio -Thank you for your inquiry about your Teams app development issue! We are checking the issue. We will get back to you shortly.

sayali-MSFT commented 16 hours ago

Hello @midhunloopio - At the moment, we are unable to replicate the issue you're experiencing.

We are following the guidelines in the document for the YML file. Could you kindly review it and let us know if everything looks correct on your end? Document Link-https://learn.microsoft.com/en-us/microsoft-365-copilot/extensibility/build-declarative-agents?tabs=ttk&tutorial-step=7#posts-api-openapi-description-document

If possible, try simplifying the OpenAPI document by removing any complex or nested structures. This can help isolate the issue and make it easier to identify the root cause.

image

midhunloopio commented 14 hours ago

Hi @sayali-MSFT , much thanks for looking into my issue. Did you try it with the openAPI document I shared ? if not could you try with that ? The one I shared is a very simplified version of the document we actually use. It consists of only the one path where I have managed to isolate the issue. I have already mentioned here :

I have figured out what the cause could be :

I have a path for which the query param that is to be passed must be a JSON string. And according to the [openAPI doc](https://swagger.io/docs/specification/v3_0/describing-parameters/#schema-vs-content) , this is a unique case and we have to use content along with schema to get this working.
This is causing the specParser to fail with this error. I tried removing the content part and provided style and explode values and it is picking this openAPI doc up