theonedev/onedev · error · EntityNotFoundException

Label spec not found:

Error message

Label spec not found: 

What it means

BaseEntityLabelService.sync applies a requested set of label names to an entity. For each name not already on the entity, it looks up the label spec via labelSpecService.find; if the spec does not exist it throws EntityNotFoundException. Labels must reference pre-defined label specs, so applying an undefined label is rejected.

Source

Thrown at server-core/src/main/java/io/onedev/server/service/impl/BaseEntityLabelService.java:36

	@Inject
	private LabelSpecService labelSpecService;

	@Transactional
	public void sync(LabelSupport<T> entity, Collection<String> labelNames) {
		var labelsToRemove = new HashSet<>();
		entity.getLabels().stream()
				.filter(it->!labelNames.contains(it.getSpec().getName()))
				.forEach(it-> {delete(it); labelsToRemove.add(it);});
		entity.getLabels().removeAll(labelsToRemove);
		
		Collection<String> existingLabelNames = entity.getLabels().stream()
				.map(it->it.getSpec().getName())
				.collect(Collectors.toSet());
		labelNames.stream().filter(it->!existingLabelNames.contains(it)).forEach(it-> {
			var labelSpec = labelSpecService.find(it);
			if (labelSpec == null)
				throw new EntityNotFoundException("Label spec not found: " + it);
			var label = newEntityLabel((AbstractEntity) entity, labelSpec);
			dao.persist(label);
			entity.getLabels().add(label);
		});
	}

	protected abstract T newEntityLabel(AbstractEntity entity, LabelSpec spec);
	
}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Create the missing label spec (project or global label settings) with the exact name used.
  2. Correct the label name in the calling code/script to match an existing spec.
  3. List available specs via labelSpecService to confirm the exact spelling.
  4. If the spec was renamed, update all automation to the new name.

Example fix

// before
entityLabelService.sync(issue, List.of("bug", "priorty-high")); // 'priorty-high' spec missing
// after
entityLabelService.sync(issue, List.of("bug", "priority-high"));
Defensive patterns

Strategy: validation

Validate before calling

List<String> validNames = labelSpecService.findAll().stream().map(LabelSpec::getName).collect(toList());
List<String> bad = labelNames.stream().filter(n -> !validNames.contains(n)).collect(toList());
if (!bad.isEmpty()) throw new IllegalArgumentException("Unknown label specs: " + bad);

Type guard

function resolveLabelSpec(name, specs) {
  const spec = specs.find(s => s.name === name);
  if (!spec) throw new Error(`Label spec not found: ${name}`);
  return spec;
}

Try / catch

try {
  entityLabelService.sync(entity, labelNames);
} catch (EntityNotFoundException e) {
  logger.error("Sync aborted; create the missing label spec first", e);
}

Prevention

When it happens

Trigger: Calling entityLabelService.sync(entity, labelNames) (or APIs/build scripts setting labels) with a name that has no matching LabelSpec defined in the project/administration label settings.

Common situations: Typo in label name; label spec deleted or renamed while automation still references the old name; scripts copied between projects with different label sets; case-sensitivity mismatch.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/7053c17023533923. Report an issue: GitHub.