Skip to content
Open
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
8 changes: 8 additions & 0 deletions pkg/cmd/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ func runRegisterSteps(ctx context.Context, t *terminal.Terminal, s RegisterStore
NodeSpec: toProtoNodeSpec(hwProfile),
}))
if err != nil {
// Newer dev-plane returns CodeAlreadyExists for a duplicate node name.
// Older dev-plane leaks the raw Postgres unique-constraint error, so we
// also match the constraint name for backwards compatibility until the
// server change is fully rolled out.
if connect.CodeOf(err) == connect.CodeAlreadyExists ||
strings.Contains(err.Error(), "externalnode_organization_id_name") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't need to worry about backwards compatibility here as we can just ship the devplane side immediately, and this index name could be changed in the future.

return nil, fmt.Errorf("a node with this name already exists")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should probably just use the inner error message here, as that will contain the true "node already exists" message

}
return nil, fmt.Errorf("failed to register node: %w", err)
}

Expand Down
Loading