chore: panic if a random name cannot be created

If that happens so much will go wrong that there is no point in
continuing to do anything. It simplifies the requirements of the
caller: it may be a function that is assumed to never error.
This commit is contained in:
Earl Warren 2025-08-14 09:41:26 +02:00
parent 41f8b03b79
commit 8944a6ef3f
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 14 additions and 18 deletions

View file

@ -167,11 +167,7 @@ func (h *Handler) ExternalURL() string {
// The function returns the 32-bit random key which the run will use to identify itself.
func (h *Handler) AddRun(data RunData) (string, error) {
for retries := 0; retries < 3; retries++ {
key, err := common.RandName(4)
if err != nil {
return "", errors.New("Could not generate the run id")
}
key := common.MustRandName(4)
_, loaded := h.runs.LoadOrStore(key, data)
if !loaded {
// The key was unique and added successfully