AlistGo/alist · warning

label have binding relationships

Error message

label have binding relationships

What it means

DeleteLabelById refuses to delete a label that still has file-binding relationships for the user, checked via db.GetLabelFileBinDingByLabelIdExists(id, userId). Deleting would orphan those bindings, so the op requires the label to be unbound first. The label itself is confirmed to exist before this check.

Source

Thrown at internal/op/label.go:16

package op

import (
	"context"
	"github.com/alist-org/alist/v3/internal/db"
	"github.com/pkg/errors"
)

func DeleteLabelById(ctx context.Context, id, userId uint) error {
	_, err := db.GetLabelById(id)
	if err != nil {
		return errors.WithMessage(err, "failed get label")
	}

	if db.GetLabelFileBinDingByLabelIdExists(id, userId) {
		return errors.New("label have binding relationships")
	}

	// delete the label in the database
	if err := db.DeleteLabelById(id); err != nil {
		return errors.WithMessage(err, "failed delete label in database")
	}
	return nil
}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Remove the label from all files that use it, then retry the delete
  2. Use the UI's bulk unbind feature if available before deleting the label
  3. Check remaining bindings programmatically before offering delete in your own UI

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

// Before deleting a label
if db.GetLabelFileBinDingByLabelIdExists(labelId, userId) {
    return errors.New("unbind label from all files first")
}

Prevention

When it happens

Trigger: Calling op.DeleteLabelById(ctx, labelId, userId) while any file still carries that label (binding rows exist for that label id and user).

Common situations: Bulk-labeled files then attempting label cleanup; UI delete button hit without unbinding; shared labels across many objects.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/7e0d09cc5a87fc13. Report an issue: GitHub.