From c3b794e5bf64707ea4eebad66849afa33e48dc34 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 13 Feb 2024 14:55:09 +0100 Subject: [PATCH 1/2] Skip for_each_task when generating the bundle schema --- bundle/schema/openapi.go | 7 +++++++ bundle/schema/schema.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/bundle/schema/openapi.go b/bundle/schema/openapi.go index 0b64c43e3c7..6564babac60 100644 --- a/bundle/schema/openapi.go +++ b/bundle/schema/openapi.go @@ -71,6 +71,13 @@ func (reader *OpenapiReader) safeResolveRefs(root *jsonschema.Schema, tracker *t return reader.traverseSchema(root, tracker) } key := *root.Reference + + // HACK to unblock CLI release (13th Feb 2024). This is temporary until proper + // support for recursive types is added to the docs generator. + if strings.Contains(key, "ForEachTask") { + return root, nil + } + if tracker.hasCycle(key) { // self reference loops can be supported however the logic is non-trivial because // cross refernce loops are not allowed (see: http://json-schema.org/understanding-json-schema/structuring.html#recursion) diff --git a/bundle/schema/schema.go b/bundle/schema/schema.go index 8b5c36d12c9..3cb6d48525d 100644 --- a/bundle/schema/schema.go +++ b/bundle/schema/schema.go @@ -92,6 +92,12 @@ func jsonSchemaType(golangType reflect.Type) (jsonschema.Type, error) { // // - tracker: Keeps track of types / traceIds seen during recursive traversal func safeToSchema(golangType reflect.Type, docs *Docs, traceId string, tracker *tracker) (*jsonschema.Schema, error) { + // HACK to unblock CLI release (13th Feb 2024). This is temporary until proper + // support for recursive types is added to the schema generator. + if traceId == "for_each_task" { + return nil, nil + } + // WE ERROR OUT IF THERE ARE CYCLES IN THE JSON SCHEMA // There are mechanisms to deal with cycles though recursive identifiers in json // schema. However if we use them, we would need to make sure we are able to detect From f9c3c0783d6db6a02e59e4fe5e731fc8d849d0f4 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 13 Feb 2024 15:04:32 +0100 Subject: [PATCH 2/2] add pr backlink --- bundle/schema/openapi.go | 2 +- bundle/schema/schema.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bundle/schema/openapi.go b/bundle/schema/openapi.go index 6564babac60..fe329e7ac45 100644 --- a/bundle/schema/openapi.go +++ b/bundle/schema/openapi.go @@ -73,7 +73,7 @@ func (reader *OpenapiReader) safeResolveRefs(root *jsonschema.Schema, tracker *t key := *root.Reference // HACK to unblock CLI release (13th Feb 2024). This is temporary until proper - // support for recursive types is added to the docs generator. + // support for recursive types is added to the docs generator. PR: https://github.com/databricks/cli/pull/1204 if strings.Contains(key, "ForEachTask") { return root, nil } diff --git a/bundle/schema/schema.go b/bundle/schema/schema.go index 3cb6d48525d..7153f38f60f 100644 --- a/bundle/schema/schema.go +++ b/bundle/schema/schema.go @@ -93,7 +93,7 @@ func jsonSchemaType(golangType reflect.Type) (jsonschema.Type, error) { // - tracker: Keeps track of types / traceIds seen during recursive traversal func safeToSchema(golangType reflect.Type, docs *Docs, traceId string, tracker *tracker) (*jsonschema.Schema, error) { // HACK to unblock CLI release (13th Feb 2024). This is temporary until proper - // support for recursive types is added to the schema generator. + // support for recursive types is added to the schema generator. PR: https://github.com/databricks/cli/pull/1204 if traceId == "for_each_task" { return nil, nil }