Skip to content

Fix the issue where multiple identical breaks UI#233

Merged
chrisghill merged 1 commit intomainfrom
hotfix/multiple-ids-breaks-ui
Apr 22, 2026
Merged

Fix the issue where multiple identical breaks UI#233
chrisghill merged 1 commit intomainfrom
hotfix/multiple-ids-breaks-ui

Conversation

@chrisghill
Copy link
Copy Markdown
Member

@chrisghill chrisghill commented Apr 22, 2026

If a params schema has multiple $id fields that are identical, it breaks the UI (due to a validation library we use??). We don't need $id in params, but we need it in artifacts and connections. So this change will conditionally strip any $id fields that are pulled in via $ref statements in the params and UI schemas.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an opt-in mechanism during schema dereferencing to remove duplicated "$id" fields (which can cause the UI to fail) when dereferencing params and ui schemas, while keeping "$id" for artifacts and connections.

Changes:

  • Add StripID to definition.DereferenceOptions and conditionally delete "$id" when dereferencing Massdriver remote refs.
  • Update bundle schema dereferencing to pass StripID=true for Params/UI and false for Artifacts/Connections.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/definition/dereference.go Adds StripID option and strips "$id" from Massdriver-referenced schemas when enabled.
internal/bundle/dereference.go Passes StripID per schema type (Params/UI vs Artifacts/Connections).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 31 to 35
if task.schema == nil {
*task.schema = map[string]any{
"properties": make(map[string]any),
}
}
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.

The nil check here is ineffective: task.schema is a pointer created via &b.Params/etc and will never be nil. If the intent is to initialize missing schemas, this should check *task.schema == nil (or len(*task.schema)==0 depending on desired semantics) before assigning the default map; otherwise a nil map schema will flow into DereferenceSchema and later fail the map type assertion.

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +123
// 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")
}
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.
Comment on lines +20 to +21
Client *client.Client
Cwd string
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.
@chrisghill chrisghill merged commit e27dd8e into main Apr 22, 2026
14 checks passed
@chrisghill chrisghill deleted the hotfix/multiple-ids-breaks-ui branch April 22, 2026 20:13
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

Successfully merging this pull request may close these issues.

3 participants