Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions internal/bundle/dereference.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ import (
func (b *Bundle) DereferenceSchemas(path string, mdClient *client.Client) error {
cwd := filepath.Dir(path)

// The stripID is a hack to get around the issue of the UI choking if the params schema has 2 or more of the same $id in it.
// We need the "$id" in artifacts and connections, but we need to strip it out of params and ui schemas, hence the conditional.
// This logic should be removed when we have a better solution for this in the UI/API - probably after resource types are in OCI
tasks := []struct {
schema *map[string]any
label string
schema *map[string]any
label string
stripID bool
}{
{schema: &b.Artifacts, label: "artifacts"},
{schema: &b.Params, label: "params"},
{schema: &b.Connections, label: "connections"},
{schema: &b.UI, label: "ui"},
{schema: &b.Artifacts, label: "artifacts", stripID: false},
{schema: &b.Params, label: "params", stripID: true},
{schema: &b.Connections, label: "connections", stripID: false},
{schema: &b.UI, label: "ui", stripID: true},
}

for _, task := range tasks {
Expand All @@ -30,7 +34,7 @@ func (b *Bundle) DereferenceSchemas(path string, mdClient *client.Client) error
}
}

dereferencedSchema, err := definition.DereferenceSchema(*task.schema, definition.DereferenceOptions{Client: mdClient, Cwd: cwd})
dereferencedSchema, err := definition.DereferenceSchema(*task.schema, definition.DereferenceOptions{Client: mdClient, Cwd: cwd, StripID: task.stripID})

if err != nil {
return err
Expand Down
12 changes: 10 additions & 2 deletions internal/definition/dereference.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import (

// DereferenceOptions holds configuration for schema dereferencing operations.
type DereferenceOptions struct {
Client *client.Client
Cwd string
Client *client.Client
Cwd string
Comment on lines +20 to +21
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StripID reads like it will remove "$id" everywhere, but the current implementation only deletes it for Massdriver remote refs (in dereferenceMassdriverRef). To avoid misuse/confusion for future callers, consider renaming the option (or documenting it in the field comment) to make the scope explicit (e.g., only applies to Massdriver-referenced schemas).

Suggested change
Client *client.Client
Cwd string
Client *client.Client
Cwd string
// StripID removes the top-level "$id" only from schemas loaded via Massdriver remote refs
// in dereferenceMassdriverRef. It does not strip "$id" from all schemas encountered during dereferencing.

Copilot uses AI. Check for mistakes.
StripID bool
}

// relativeFilePathPattern only accepts relative file path prefixes "./" and "../"
Expand Down Expand Up @@ -114,6 +115,13 @@ func dereferenceMassdriverRef(hydratedSchema map[string]any, schema map[string]a
}
}

// This is a hack to get around the issue of the UI choking if the params schema has 2 or more of the same $id in it.
// We need the "$id" in artifacts and connections, but we need to strip it out of params and ui schemas, hence the conditional.
// This logic should be removed when we have a better solution for this in the UI/API - probably after resource types are in OCI
if opts.StripID {
delete(referencedSchema, "$id")
}
Comment on lines +118 to +123
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces new behavior (conditionally removing "$id" from dereferenced Massdriver schemas) but there is no test coverage validating that StripID=true actually strips "$id" and StripID=false preserves it. Consider adding/adjusting a unit test in internal/definition/dereference_test.go that mocks a remote schema containing a "$id" and asserts the output based on the StripID option.

Copilot uses AI. Check for mistakes.

hydratedSchema, err = replaceRef(schema, referencedSchema, opts)
if err != nil {
return hydratedSchema, err
Expand Down
Loading