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

Seems to be a circular definition error using OASModel with Argo Workflows OpenAPI spec #2282

Open
lukeczapla opened this issue Jan 13, 2025 · 0 comments

Comments

@lukeczapla
Copy link

lukeczapla commented Jan 13, 2025

Describe the bug

Working with Argo Workflows API that has this OpenAPI spec (made a few minor changes just with the Swagger to OpenAPI 3.0 with a simple converter):
https://github.com/argoproj/argo-workflows/blob/main/api/openapi-spec/swagger.json

It appears that when I use a call to define types like this or put these definitions inline in my code [openapi.ts is just exporting this spec]:

type ATemplate = OASModel<NormalizeOAS<typeof openapi>, 'io.argoproj.workflow.v1alpha1.Template'>;
type ADAGTask = OASModel<NormalizeOAS<typeof openapi>, 'io.argoproj.workflow.v1alpha1.DAGTask'>;

I am getting some errors like this:

The expected type comes from property 'dag' which is declared here on type '{ name?: string; inputs?: { parameters?: { description?: string; value?: string; default?: string; enum?: string[]; globalName?: string; valueFrom?: { event?: string; path?: string; default?: string; expression?: string; ... 4 more ...; supplied?: { ...; }; }; name: string; }[]; artifacts?: { ...; }[]; }; ... 36 mor...'

Type of property '"inline"' circularly references itself in mapped type '{ arguments: { type: "object"; values: { artifacts: IntersectArraySerializationParams<{ type: "object"; values: { archive: { type: "object"; values: { none: { type: "object"; values: {}; required: never; isOpen: true; openProps: Any; closeOnResolve: false; isSerialized: false; deserialized: never; }; tar: { ...; }; ...'.

Type of property '"steps"' circularly references itself in mapped type '{ [KEY in keyof { activeDeadlineSeconds: { $id: "#/components/schemas/io.k8s.apimachinery.pkg.util.intstr.IntOrString"; type: "string"; }; affinity: Omit<{ $id: "#/components/schemas/io.k8s.api.core.v1.Affinity"; description: "Affinity is a group of affinity scheduling rules."; type: "object"; properties: { ...; }; ...'.

Type of property '"tasks"' circularly references itself in mapped type '{ failFast: { type: "primitive"; value: boolean; isSerialized: false; deserialized: never; }; target: { type: "primitive"; value: string; isSerialized: false; deserialized: never; }; tasks: IntersectArraySerializationParams<{ type: "object"; ... 6 more ...; deserialized: never; }, _$Array<...>, Any>; }'.

So I tried to compile it with tsc and the whole thing crashed:

lczapla@CPC-LCzap-XCFDL:~/github/development/core/apps/api$ pnpm tsc

<--- Last few GCs --->

[11210:0x737e4b0]   189014 ms: Scavenge 2040.5 (2082.0) -> 2039.1 (2082.3) MB, 6.59 / 0.00 ms  (average mu = 0.261, current mu = 0.320) allocation failure;
[11210:0x737e4b0]   189031 ms: Scavenge 2040.8 (2082.3) -> 2039.4 (2082.3) MB, 7.98 / 0.00 ms  (average mu = 0.261, current mu = 0.320) allocation failure;
[11210:0x737e4b0]   189188 ms: Scavenge 2041.1 (2082.3) -> 2039.7 (2086.5) MB, 93.89 / 0.00 ms  (average mu = 0.261, current mu = 0.320) allocation failure;


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xc9e850 node::Abort() [node]
 2: 0xb720ff  [node]
 3: 0xec1a70 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0xec1d57 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 5: 0x10d3dc5  [node]
 6: 0x10d4354 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 7: 0x10eb244 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
 8: 0x10eba5c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0x10edbba v8::internal::Heap::HandleGCRequest() [node]
10: 0x1058fd7 v8::internal::StackGuard::HandleInterrupts() [node]
11: 0x14fab32 v8::internal::Runtime_StackGuardWithGap(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x7f8c7fed9ef6
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command was killed with SIGABRT (Aborted): tsc

So as far as I can tell, Template (io.argoproj.workflow.v1alpha1.Template) references DAGTask (io.argoproj.workflow.v1alpha1.DAGTask) in its dag.tasks array field (the dag field is a io.argoproj.workflow.v1alpha1.DAGTemplate with a tasks field that's an array of DAGTask objects) and DAGTask references Template in its inline field and so I guess it's just looping around endlessly.

To Reproduce Steps to reproduce the behavior:

Use this same OpenAPI definition and be able to define a Template with a dag field. Or just use the two definitions lines above since that seemed to already trigger the errors.

Expected behavior

It should compile fine and not have any circular definition errors.

Environment:

  • OS: Linux (Ubuntu)
  • "fets": "^0.8.4"
  • NodeJS: v20.10.0

Additional context
Sort of a newbie here using feTS but could use any suggestions. Thanks!

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

No branches or pull requests

1 participant