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

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 this issue Nov 21, 2024 · 6 comments
Assignees
Labels

Comments

@midhunloopio
Copy link

midhunloopio commented Nov 21, 2024

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 :

  • 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 , 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

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: [email protected]
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:
          - stackID: 2
            categoryID: 5
        searchQuery: What is Loopio?
        language: en
      minProperties: 1
    DateTimeRangeFilter:
      type: object
      minProperties: 1
      example:
        gte: '2020-01-01T00:00:00Z'
      maxProperties: 2
      additionalProperties: false
      properties:
        eq:
          type: string
          format: date-time
          description: Equals to
        gt:
          type: string
          format: date-time
          description: Greater than
        gte:
          type: string
          format: date-time
          description: Greater than or equals to
        lt:
          type: string
          format: date-time
          description: Less than
        lte:
          type: string
          format: date-time
          description: Less than or equals to
    LibraryLocation:
      type: object
      properties:
        stackID:
          type: integer
        categoryID:
          type: integer
          nullable: true
          description: A categoryID should only be set when a stackID is defined
        subCategoryID:
          type: integer
          nullable: true
          description: A subCategoryID value should only be set when a categoryID is defined
      required:
        - stackID
      example:
        stackID: 3
        categoryID: 5
        subCategoryID: 2        
paths:
  /libraryEntries:
    get:
      parameters:
        - $ref: '#/components/parameters/Page'
        - name: pageSize
          in: query
          description: The numbers of items to return
          schema:
            type: integer
            minimum: 1
            maximum: 10000
            exclusiveMinimum: false
            example: 10
            default: 10
          required: false
        - name: filter
          in: query
          description: Passing in an empty string for language will instead show entries in every language.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LibrarySearchOptions'
          required: false
      tags:
        - Library Entries
      summary: List Library Entries you can interact with
      operationId: listLibraryEntries
  1. See error

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):

  • OS: [e.g. MacOS 14.6.1]
  • Version [Teams Toolkit : v5.10.1]
Copy link
Contributor

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.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Nov 21, 2024
@sayali-MSFT
Copy link

@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
Copy link

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
Copy link
Author

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

@SLdragon
Copy link
Contributor

Hi, @midhunloopio , thanks for your feedback:

I reviewed your OpenAPI specification file and noticed some issues (see the attached image):

image

You can address these issues and try again

@adashen adashen removed the needs attention This issue needs the attention of a contributor. label Nov 26, 2024
@sayali-MSFT
Copy link

@midhunloopio ,
Have you had a chance to review the points mentioned by @SLdragon above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants