theonedev/onedev · error · ValidationException

Opposite side of link spec not allowed to link to the source

Error message

Opposite side of link spec not allowed to link to the source issue

What it means

For a bidirectional spec, validate() checks the source issue against the OPPOSITE spec's issue query as well. This error is thrown when the source issue fails getSpec().getOpposite().getParsedIssueQuery(...) evaluated in the source project — the spec disallows the source side of the link.

Source

Thrown at server-core/src/main/java/io/onedev/server/model/IssueLink.java:104

		if (getSource().equals(getTarget()))
			throw new ValidationException("Cannot link to self");
		if (getSpec().getOpposite() != null) {
			if (getSource().getTargetLinks().stream()
					.anyMatch(it -> it.getSpec().equals(getSpec()) && it.getTarget().equals(getTarget())))
				throw new ValidationException("Source issue already linked to target issue via specified link spec");
			if (!getSpec().isMultiple()
					&& getSource().getTargetLinks().stream().anyMatch(it -> it.getSpec().equals(getSpec())))
				throw new ValidationException(
						"Link spec is not multiple and the source issue is already linked to another issue via this link spec");
			if (!getSpec().getParsedIssueQuery(getSource().getProject()).matches(getTarget()))
				throw new ValidationException("Link spec not allowed to link to the target issue");
			if (!getSpec().getOpposite().isMultiple()
					&& getTarget().getSourceLinks().stream().anyMatch(it -> it.getSpec().equals(getSpec())))
				throw new ValidationException(
						"Opposite side of link spec is not multiple and the target issue is already linked to another issue via this link spec");
			if (!getSpec().getOpposite().getParsedIssueQuery(getSource().getProject())
					.matches(getSource()))
				throw new ValidationException("Opposite side of link spec not allowed to link to the source issue");
		} else {
			if (getSource().getLinks().stream().anyMatch(it -> it.getSpec().equals(getSpec())
					&& it.getLinked(getSource()).equals(getTarget())))
				throw new ValidationException("Specified issues already linked via specified link spec");
			if (!getSpec().isMultiple()
					&& getSource().getLinks().stream().anyMatch(it -> it.getSpec().equals(getSpec())))
				throw new ValidationException(
						"Link spec is not multiple and source issue is already linked to another issue via this link spec");
			var parsedIssueQuery = getSpec().getParsedIssueQuery(getSource().getProject());
			if (!parsedIssueQuery.matches(getSource()) || !parsedIssueQuery.matches(getTarget()))
				throw new ValidationException("Link spec not allowed to link specified issues");
		}
	}
}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Make sure the source issue satisfies the opposite spec's issue query (change its state/type if appropriate).
  2. Relax the opposite spec's issue query in Administration > Links.
  3. Use a different, less restrictive link spec.
Defensive patterns

Strategy: validation

Validate before calling

var oppositeQuery = link.getSpec().getOpposite().getParsedIssueQuery(link.getSource().getProject());
if (!oppositeQuery.matches(link.getSource())) throw new IllegalStateException("source not allowed by opposite query");

Try / catch

try { IssueLink.createLink(link); } catch (ValidationException e) { // inform user the source issue violates the opposite spec query }

Prevention

When it happens

Trigger: createLink where getSpec().getOpposite() defines an issue query and getSource() does not match it.

Common situations: Opposite query restricts linking by state (e.g. only open issues can be linked) and the source issue is closed; the source issue is of a type excluded by the opposite query; query was changed between drafting and saving the link.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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