Skip to content

Commit 8189f8c

Browse files
committed
Filter OpenAPI enum values by launch stage to prevent flip-flopping
## Changes Filter out enum values with DEVELOPMENT or PRIVATE_PREVIEW launch stages when extracting annotations from the OpenAPI spec. Only values with GA, PUBLIC_PREVIEW, or PUBLIC_BETA stages are included in the generated schema. ## Why Different OpenAPI spec versions have inconsistent visibility filtering, causing enum values like LIQUID to appear and disappear across commits. This made the annotations file non-deterministic depending on which spec was used. Evidence of flip-flopping (newest to oldest): - a6fbd57 Add support for alerts to DABs (#4004) - LIQUID re-added - ecc9d54 Regenerate autogenerated files (#3981) - LIQUID removed - 89b2786 Upgrade go sdk to 0.85.0 (#3769) - LIQUID first added
1 parent daef3df commit 8189f8c

File tree

5 files changed

+60
-142
lines changed

5 files changed

+60
-142
lines changed

bundle/internal/schema/annotations_openapi.yml

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,8 +1258,6 @@ github.com/databricks/databricks-sdk-go/service/apps.ComputeSize:
12581258
MEDIUM
12591259
- |-
12601260
LARGE
1261-
- |-
1262-
LIQUID
12631261
github.com/databricks/databricks-sdk-go/service/apps.ComputeState:
12641262
"_":
12651263
"enum":
@@ -2914,11 +2912,6 @@ github.com/databricks/databricks-sdk-go/service/jobs.JobSourceDirtyState:
29142912
Possible values are:
29152913
* `NOT_SYNCED`: The job is not yet synced with the remote job specification. Import the remote job specification from UI to make the job fully synced.
29162914
* `DISCONNECTED`: The job is temporary disconnected from the remote job specification and is allowed for live edit. Import the remote job specification again from UI to make the job fully synced.
2917-
"enum":
2918-
- |-
2919-
NOT_SYNCED
2920-
- |-
2921-
DISCONNECTED
29222915
github.com/databricks/databricks-sdk-go/service/jobs.JobsHealthMetric:
29232916
"_":
29242917
"description": |-
@@ -2988,15 +2981,7 @@ github.com/databricks/databricks-sdk-go/service/jobs.ModelTriggerConfiguration:
29882981
If set, the trigger starts a run only after no model updates have occurred for the specified time
29892982
and can be used to wait for a series of model updates before triggering a run. The
29902983
minimum allowed value is 60 seconds.
2991-
github.com/databricks/databricks-sdk-go/service/jobs.ModelTriggerConfigurationCondition:
2992-
"_":
2993-
"enum":
2994-
- |-
2995-
MODEL_CREATED
2996-
- |-
2997-
MODEL_VERSION_READY
2998-
- |-
2999-
MODEL_ALIAS_SET
2984+
github.com/databricks/databricks-sdk-go/service/jobs.ModelTriggerConfigurationCondition: {}
30002985
github.com/databricks/databricks-sdk-go/service/jobs.NotebookTask:
30012986
"base_parameters":
30022987
"description": |-
@@ -3682,21 +3667,6 @@ github.com/databricks/databricks-sdk-go/service/pipelines.DayOfWeek:
36823667
"description": |-
36833668
Days of week in which the window is allowed to happen.
36843669
If not specified all days of the week will be used.
3685-
"enum":
3686-
- |-
3687-
MONDAY
3688-
- |-
3689-
TUESDAY
3690-
- |-
3691-
WEDNESDAY
3692-
- |-
3693-
THURSDAY
3694-
- |-
3695-
FRIDAY
3696-
- |-
3697-
SATURDAY
3698-
- |-
3699-
SUNDAY
37003670
github.com/databricks/databricks-sdk-go/service/pipelines.DeploymentKind:
37013671
"_":
37023672
"description": |-
@@ -3880,10 +3850,6 @@ github.com/databricks/databricks-sdk-go/service/pipelines.IngestionSourceType:
38803850
MYSQL
38813851
- |-
38823852
POSTGRESQL
3883-
- |-
3884-
REDSHIFT
3885-
- |-
3886-
SQLDW
38873853
- |-
38883854
SQLSERVER
38893855
- |-
@@ -3908,26 +3874,6 @@ github.com/databricks/databricks-sdk-go/service/pipelines.IngestionSourceType:
39083874
SHAREPOINT
39093875
- |-
39103876
DYNAMICS365
3911-
- |-
3912-
CONFLUENCE
3913-
- |-
3914-
META_MARKETING
3915-
- |-
3916-
GOOGLE_ADS
3917-
- |-
3918-
TIKTOK_ADS
3919-
- |-
3920-
SALESFORCE_MARKETING_CLOUD
3921-
- |-
3922-
HUBSPOT
3923-
- |-
3924-
WORKDAY_HCM
3925-
- |-
3926-
GUIDEWIRE
3927-
- |-
3928-
ZENDESK
3929-
- |-
3930-
FOREIGN_CATALOG
39313877
github.com/databricks/databricks-sdk-go/service/pipelines.ManualTrigger: {}
39323878
github.com/databricks/databricks-sdk-go/service/pipelines.NotebookLibrary:
39333879
"path":
@@ -4277,13 +4223,6 @@ github.com/databricks/databricks-sdk-go/service/pipelines.TableSpecificConfigScd
42774223
"_":
42784224
"description": |-
42794225
The SCD type to use to ingest the table.
4280-
"enum":
4281-
- |-
4282-
SCD_TYPE_1
4283-
- |-
4284-
SCD_TYPE_2
4285-
- |-
4286-
APPEND_ONLY
42874226
github.com/databricks/databricks-sdk-go/service/serving.Ai21LabsConfig:
42884227
"ai21labs_api_key":
42894228
"description": |-

bundle/internal/schema/annotations_openapi_overrides.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,10 @@ github.com/databricks/cli/bundle/config/resources.SqlWarehousePermissionLevel:
645645
CAN_MONITOR
646646
- |-
647647
CAN_VIEW
648+
github.com/databricks/cli/bundle/config/resources.SyncedDatabaseTable:
649+
"lifecycle":
650+
"description": |-
651+
PLACEHOLDER
648652
github.com/databricks/cli/bundle/config/resources.Volume:
649653
"_":
650654
"markdown_description": |-

bundle/internal/schema/parser.go

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,39 @@ type openapiParser struct {
3030

3131
const RootTypeKey = "_"
3232

33+
// launchStagesIncluded defines which launch stages should be included in the schema.
34+
// Enum values with launch stages not in this list will be filtered out.
35+
var launchStagesIncluded = []string{
36+
"GA",
37+
"PUBLIC_PREVIEW",
38+
"PUBLIC_BETA",
39+
}
40+
41+
// filterEnumsByLaunchStage filters enum values based on their launch stage.
42+
// Only enum values whose launch stage is in launchStagesIncluded are kept.
43+
// If an enum value has no metadata, it is included by default.
44+
func filterEnumsByLaunchStage(enum []any, metadata map[string]jsonschema.EnumValueMetadata) []any {
45+
if metadata == nil {
46+
return enum
47+
}
48+
49+
var filtered []any
50+
for _, v := range enum {
51+
s, ok := v.(string)
52+
if !ok {
53+
// Non-string enum values are included as-is
54+
filtered = append(filtered, v)
55+
continue
56+
}
57+
58+
meta, hasMeta := metadata[s]
59+
if !hasMeta || slices.Contains(launchStagesIncluded, meta.LaunchStage) {
60+
filtered = append(filtered, v)
61+
}
62+
}
63+
return filtered
64+
}
65+
3366
func newParser(path string) (*openapiParser, error) {
3467
b, err := os.ReadFile(path)
3568
if err != nil {
@@ -160,14 +193,15 @@ func (p *openapiParser) extractAnnotations(typ reflect.Type, outputPath, overrid
160193
preview = ""
161194
}
162195
outputOnly := isOutputOnly(ref)
163-
if ref.Description != "" || ref.Enum != nil || ref.Deprecated || ref.DeprecationMessage != "" || preview != "" || outputOnly != nil {
196+
filteredEnum := filterEnumsByLaunchStage(ref.Enum, ref.EnumMetadata)
197+
if ref.Description != "" || filteredEnum != nil || ref.Deprecated || ref.DeprecationMessage != "" || preview != "" || outputOnly != nil {
164198
if ref.Deprecated && ref.DeprecationMessage == "" {
165199
ref.DeprecationMessage = "This field is deprecated"
166200
}
167201

168202
pkg[RootTypeKey] = annotation.Descriptor{
169203
Description: ref.Description,
170-
Enum: ref.Enum,
204+
Enum: filteredEnum,
171205
DeprecationMessage: ref.DeprecationMessage,
172206
Preview: preview,
173207
OutputOnly: outputOnly,
@@ -200,7 +234,7 @@ func (p *openapiParser) extractAnnotations(typ reflect.Type, outputPath, overrid
200234

201235
pkg[k] = annotation.Descriptor{
202236
Description: description,
203-
Enum: refProp.Enum,
237+
Enum: filterEnumsByLaunchStage(refProp.Enum, refProp.EnumMetadata),
204238
Preview: preview,
205239
DeprecationMessage: refProp.DeprecationMessage,
206240
OutputOnly: isOutputOnly(*refProp),

bundle/schema/jsonschema.json

Lines changed: 9 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/jsonschema/extension.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,13 @@ type Extension struct {
6565
// FieldBehaviors defines field behaviors from the OpenAPI spec (e.g. OUTPUT_ONLY)
6666
// This is used to filter out fields that should not be exposed to users
6767
FieldBehaviors []string `json:"x-databricks-field-behaviors,omitempty"`
68+
69+
// EnumMetadata contains per-enum-value metadata from the OpenAPI spec.
70+
// The key is the enum value, and the value contains metadata like launch stage.
71+
EnumMetadata map[string]EnumValueMetadata `json:"x-databricks-enum-metadata,omitempty"`
72+
}
73+
74+
// EnumValueMetadata contains metadata for a single enum value.
75+
type EnumValueMetadata struct {
76+
LaunchStage string `json:"x-databricks-launch-stage,omitempty"`
6877
}

0 commit comments

Comments
 (0)