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

Circular dependency with generated swagger metadata #2849

Open
2 of 4 tasks
Stono opened this issue Feb 19, 2024 · 5 comments
Open
2 of 4 tasks

Circular dependency with generated swagger metadata #2849

Stono opened this issue Feb 19, 2024 · 5 comments

Comments

@Stono
Copy link

Stono commented Feb 19, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Hi,
I'm trying to use the generate metadata function of the cli and getting an error when using an object type. There seems to be several historical issues showing the same thing:

#1442
#502

The metadata generates fine, however when starting the app I get:

A circular dependency has been detected (property key: \"auditLogs\"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers (\"type: () => ClassType\").","stack":"Error: A circular dependency has been detected (property key: \"auditLogs\"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers (\"type: () => ClassType\").

This is my super simple dto:

export abstract class GetUserAuditLogResponse {
  public abstract user: string
  public abstract clusters: string[]
  public abstract auditLogs: { username: string }[]
}

Minimum reproduction code

Example in comments above

Steps to reproduce

No response

Expected behavior

It to handle the array of objects

Package version

7.3.0

NestJS version

10.3.3

Node.js version

20

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@Stono
Copy link
Author

Stono commented Feb 19, 2024

This could be user error, as i'm new to this... but moving { username: string } into it's own class def "fixes" it, eg:

export abstract class AuditLogItem {
  public abstract username: string 
}

export abstract class GetUserAuditLogResponse {
  public abstract user: string
  public abstract clusters: string[]
  public abstract auditLogs: AuditLogItem[]
}

@cjam
Copy link

cjam commented Feb 29, 2024

Was experiencing the same thing on another project. After a lot of trial and error I found that my typeorm package had been updated to 0.3.20, on a hunch I rolled it back to the previous version we were using (0.3.17) which worked. I then worked my way back up and was able to install 0.3.19 without this issue, but as soon as I installed 0.3.20 it failed.

Did a little more searching and eventually found that it seems this has been logged against typeorm here typeorm/typeorm#10671

Not sure if it's the same issue or different, but adding in my meanderings anyways.

@lacuong2009
Copy link

Was experiencing the same thing on another project. After a lot of trial and error I found that my typeorm package had been updated to 0.3.20, on a hunch I rolled it back to the previous version we were using (0.3.17) which worked. I then worked my way back up and was able to install 0.3.19 without this issue, but as soon as I installed 0.3.20 it failed.

Did a little more searching and eventually found that it seems this has been logged against typeorm here typeorm/typeorm#10671

Not sure if it's the same issue or different, but adding in my meanderings anyways.

The same to me, Rollbacked typeORM to 0.3.19. it works fine

@OSA413
Copy link

OSA413 commented Mar 15, 2024

Possible duplicate of #2811

@Gavin152
Copy link

I can confirm that hard-coding typeORM to 0.3.19 fixes the issue.

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

No branches or pull requests

5 participants