-
Notifications
You must be signed in to change notification settings - Fork 216
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
Freeze/Stale when generating client #4653
Comments
The core problem seems to be with GET requests that lack parameters. In those cases, this behavior occurs, as you can see here: /v1/projects:
get:
tags:
- Project Management
summary: List Projects
description: Lists all projects
responses:
'200':
description: Projects retrieved successfully
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Project'
|
Hi @zZHorizonZz openapi: 3.0.3
info:
title: api-service API
version: 0.0.1
description: API for managing environments, projects, and private services
contact:
name: API Support
email: [email protected]
servers:
- url: http://localhost:8080
description: Local server
tags:
- name: Environment Management
description: API for managing environments
- name: Private Service Management
description: API for managing private services
- name: Project Management
description: API for managing projects
- name: Proxy Admin Service
description: API for managing proxy rules
paths:
/v1/projects:
get:
operationId: listProjects
tags:
- Project Management
summary: List Projects
description: Lists all projects
responses:
'200':
description: Projects retrieved successfully
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Project'
components:
schemas:
Action:
enum:
- ADMIN
- READ
- WRITE
type: string
Environment:
description: Represents an environment within a project
type: object
properties:
uid:
description: Unique identifier for the environment
type: string
allOf:
- $ref: '#/components/schemas/UUID'
project:
description: The project to which this environment belongs
type: object
allOf:
- $ref: '#/components/schemas/Project'
name:
description: The name of the environment
type: string
description:
description: The description of the environment
type: string
isActive:
description: Indicates if the environment is active
type: boolean
createdAt:
description: The timestamp when the environment was created
type: string
allOf:
- $ref: '#/components/schemas/LocalDateTime'
updatedAt:
description: The timestamp when the environment was last updated
type: string
allOf:
- $ref: '#/components/schemas/LocalDateTime'
active:
type: boolean
LocalDateTime:
format: date-time
type: string
example: '2022-03-10T12:15:50'
Project:
description: Represents a project containing environments
type: object
properties:
uid:
description: Unique identifier for the project
type: string
allOf:
- $ref: '#/components/schemas/UUID'
name:
description: Name of the project
type: string
description:
description: Description of the project
type: string
purpose:
description: Purpose of the project
type: string
createdBy:
description: User ID who created the project
type: string
# baseEnvironment:
# description: Base environment for the project
# type: object
# allOf:
# - $ref: '#/components/schemas/Environment'
# baseRole:
# description: Base role for the project
# type: object
# allOf:
# - $ref: '#/components/schemas/ProjectRole'
# environments:
# description: List of environments associated with the project
# type: array
# items:
# description: Represents an environment within a project
# type: object
# properties:
# uid:
# description: Unique identifier for the environment
# type: string
# allOf:
# - $ref: '#/components/schemas/UUID'
# project:
# description: The project to which this environment belongs
# type: object
# allOf:
# - $ref: '#/components/schemas/Project'
# name:
# description: The name of the environment
# type: string
# description:
# description: The description of the environment
# type: string
# isActive:
# description: Indicates if the environment is active
# type: boolean
# createdAt:
# description: The timestamp when the environment was created
# type: string
# allOf:
# - $ref: '#/components/schemas/LocalDateTime'
# updatedAt:
# description: The timestamp when the environment was last updated
# type: string
# allOf:
# - $ref: '#/components/schemas/LocalDateTime'
# active:
# type: boolean
createdAt:
description: Timestamp when the project was created
type: string
allOf:
- $ref: '#/components/schemas/LocalDateTime'
updatedAt:
description: Timestamp when the project was last updated
type: string
allOf:
- $ref: '#/components/schemas/LocalDateTime'
ProjectRole:
description: Represents a role within a project with associated permissions
type: object
properties:
uid:
description: Unique identifier for the project role
type: string
allOf:
- $ref: '#/components/schemas/UUID'
project:
description: The project to which this role belongs
type: object
allOf:
- $ref: '#/components/schemas/Project'
name:
description: Unique name of the role
type: string
displayName:
description: Display name of the role (for user interfaces)
type: string
description:
description: Description of the role's purpose
type: string
permissions:
description: List of permissions associated with the role
type: array
items:
type: object
properties:
api:
type: string
actions:
type: array
items:
$ref: '#/components/schemas/Action'
createdBy:
description: User ID who created the role
type: string
createdAt:
description: Timestamp when the role was created
type: string
allOf:
- $ref: '#/components/schemas/LocalDateTime'
updatedAt:
description: Timestamp when the role was last updated
type: string
allOf:
- $ref: '#/components/schemas/LocalDateTime'
UUID:
format: uuid
pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'
type: string
securitySchemes:
SecurityScheme:
type: http
description: Authentication
scheme: bearer
bearerFormat: Opaque This description is causing a stackoverflow due to circular references. Even if kiota could generate the code, it's most likely that compilers in most languages would complain about the result. |
After a closer look, I noticed this as well basically I'm generating OpenAPI specs based on a database model that includes references to other models. This is valid for me, as these models are retrieved lazily from database to prevent an infinite loop. However, I understand why this could be an issue in OpenAPI. Still, I think the "freeze/stale" behavior is inappropriate in this case, as the user doesn't know what happened. If there's schema validation, perhaps the generate command could throw an error. Otherwise, a timeout with details about the cause might be helpful. |
The "freeze" is caused by a stackoverflow, itself caused by infinite recursion of the engine. |
This issue occurs both with the executable on my work PC and with the dotnet tool command on my private PC. I don't recall if I tested it via a regular command prompt, but I have a script defined in my package.json file. After running yarn generate, it executes the command: "scripts": {
"generate": "kiota generate -l typescript -d http://localhost:8080/openapi?format=json -c Client -o ./src/client --co",
"type-check": "tsc --noEmit"
}, Though the behavior seems normal meaning if there is an error, it is shown in the console the output appears the same as if I executed a regular command. |
ah, it might be the environment host for node script runner that's not bubbling up the exception for some reason. |
I tried this in both the terminal and PowerShell, and the result is the same. I waited for five minutes to see if any errors would be thrown, but it's still stuck on InitializeInheritanceIndex. Windows.PowerShell.2024-05-16.14-40-46.mp4 |
What are you generating using Kiota, clients or plugins?
Kiota plugin
In what context or format are you using Kiota?
Windows executable
Client library/SDK language
TypeScript
Describe the bug
I'm trying to generate the client based on the specified OpenAPI file, but Kiota freezes when it tries to generate the client.
Expected behavior
Kiota shouldn't freeze. I don't think there's an error with the specifications, as other client generators generate valid clients from my tests.
How to reproduce
Try to generate client via generate command I'm using this:
kiota generate -l typescript -d http://localhost:8080/openapi?format=json -c Client -o ./src/client --co
Your path will be different obviously.
Open API description file
Kiota Version
1.14.0+fc4b39c65d89f7bfc8c7f1813c197e95e206da09
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
Debug output
Click to expand log
``` Warning: the TypeScript language is in preview (Preview) some features are not fully supported and source breaking changes will happen with future updates. info: Kiota.Builder.KiotaBuilder[0] Cleaning output directory dbug: Kiota.Builder.KiotaBuilder[0] kiota version 1.14.0 dbug: Kiota.Builder.KiotaBuilder[0] cache file C:\Users\daniel\AppData\Local\Temp\kiota\cache\generation\69C78F8D208172ABCCFD4741296BF1D28E5AECEC57EA6730F0559615D9FF23D5\openapi not found, downloading from http://localhost:8080/openapi?format=json info: Kiota.Builder.KiotaBuilder[0] skipping cache write for URI http://localhost:8080/openapi?format=json as it is a loopback address info: Kiota.Builder.KiotaBuilder[0] loaded description from remote source dbug: Kiota.Builder.KiotaBuilder[0] step 1 - reading the stream - took 00:00:02.1362970 warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/ - A servers entry (v3) or host + basePath + schemes properties (v2) was not present in the OpenAPI description. The root URL will need to be set manually with the request adapter. dbug: Kiota.Builder.KiotaBuilder[0] step 2 - parsing the document - took 00:00:00.1707046 dbug: Kiota.Builder.KiotaBuilder[0] step 3 - updating generation configuration from kiota extension - took 00:00:00.0001302 dbug: Kiota.Builder.KiotaBuilder[0] step 4 - filtering API paths with patterns - took 00:00:00.0050800 warn: Kiota.Builder.KiotaBuilder[0] No server url found in the OpenAPI document. The base url will need to be set when using the client. dbug: Kiota.Builder.KiotaBuilder[0] step 5 - checking whether the output should be updated - took 00:00:00.0200458 dbug: Kiota.Builder.KiotaBuilder[0] step 6 - create uri space - took 00:00:00.0053731 dbug: Kiota.Builder.KiotaBuilder[0] InitializeInheritanceIndex 00:00:00.0035627The text was updated successfully, but these errors were encountered: