fix(control-plane): show resolved ULID in delete success messages · Entire

fix(control-plane): show resolved ULID in delete success messages

8f8ec6f→main·

toothbrush·3w ago·5 files·+35 added/-3 removed

org/project/repo delete echoed the user-supplied arg, so a name-based delete confirmed a name while the operation used the resolved ULID — ambiguous where names are reused. Add resolvedRefLabel to render "name (ULID)" for names and the bare ULID otherwise.

Addresses trail #642 finding.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Sessions

c14749e12a9dView transcript

Changes

5

106 unmodified lines

107
108
109
110
110
111
112
113

106 unmodified lines

if err := c.DeleteOrg(ctx, coreapi.DeleteOrgParams{OrgId: orgID}); err != nil {
                return err
            }
            cmd.Printf("Deleted org %s\n", args[0])
            cmd.Printf("Deleted org %s\n", resolvedRefLabel(args[0], orgID))
            return nil
        })
    },

Mcmd/entire/cli/org.go+1/-1

185 unmodified lines

186
187
188
189
189
190
191
192

185 unmodified lines

if err := c.DeleteProject(ctx, coreapi.DeleteProjectParams{ProjectId: projID}); err != nil {
                return err
            }
            cmd.Printf("Deleted project %s\n", args[0])
            cmd.Printf("Deleted project %s\n", resolvedRefLabel(args[0], projID))
            return nil
        })
    },

Mcmd/entire/cli/project.go+1/-1

190 unmodified lines

191
192
193
194
194
195
196
197

190 unmodified lines

if err := c.DeleteRepo(ctx, coreapi.DeleteRepoParams{RepoId: repoID}); err != nil {
                return err
            }
            cmd.Printf("Deleted repo %s\n", args[0])
            cmd.Printf("Deleted repo %s\n", resolvedRefLabel(args[0], repoID))
            return nil
        })
    },

Mcmd/entire/cli/repo.go+1/-1

170 unmodified lines

171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

170 unmodified lines

return fmt.Errorf("no repo named %q in that project (run `entire repo list <project>` to see names, or pass a ULID)", name)

// resolvedRefLabel formats a reference for a success message so it always
// names the resolved ULID. When the user passed a ULID (ref == id) it returns
// the id alone; when they passed a name it returns "name (id)" so the message
// is unambiguous in environments where names can be reused across orgs/projects.
func resolvedRefLabel(ref, id string) string {
    if ref == id {
        return id
    }
    return fmt.Sprintf("%s (%s)", ref, id)
}

// toProjectList adapts a name-filtered project response — which returns the
// single match under the response's singular `project` field — into a slice for
// list output (empty when the field is unset).

Mcmd/entire/cli/resolveref.go+11

385 unmodified lines

386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409

385 unmodified lines

}
})
}

func TestResolvedRefLabel(t *testing.T) {
    t.Parallel()

const id = "01J0REPO000000000000000001"

t.Run("ulid passes through", func(t *testing.T) {
        t.Parallel()
        if got := resolvedRefLabel(id, id); got != id {
            t.Errorf("got %q, want %q", got, id)
        }
    })

t.Run("name includes resolved id", func(t *testing.T) {
        t.Parallel()
        want := fmt.Sprintf("acme (%s)", id)
        if got := resolvedRefLabel("acme", id); got != want {
            t.Errorf("got %q, want %q", got, want)
        }
    })
}

Mcmd/entire/cli/resolveref_test.go+21