theonedev/onedev · error · ValidationException
Link spec not allowed to link specified issues
Error message
Link spec not allowed to link specified issues
What it means
For a unidirectional link spec, validate() applies the spec's issue query to BOTH ends: the link is rejected unless parsedIssueQuery matches both the source and the target issue. This error is thrown when either endpoint fails the spec's query.
Source
Thrown at server-core/src/main/java/io/onedev/server/model/IssueLink.java:115
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
- Change the non-matching issue's state/type/fields so it satisfies the spec's query.
- Update the link spec's issue query to permit the intended issues.
- Pick issues matching the query or a different link spec.
Defensive patterns
Strategy: validation
Validate before calling
var q = spec.getParsedIssueQuery(source.getProject());
if (!q.matches(source) || !q.matches(target)) throw new IllegalStateException("both issues must match spec query"); Try / catch
try { IssueLink.createLink(link); } catch (ValidationException e) { // report that the spec's issue query rejects one endpoint } Prevention
- Check both endpoints against the spec query before linking
- Keep spec queries permissive enough for intended workflows
- Re-validate links after changing issue types/states
When it happens
Trigger: createLink where the spec (opposite == null) defines an issue query and !query.matches(source) || !query.matches(target) in the source project.
Common situations: Spec restricted to certain issue types/states (e.g. only 'Task' issues may be linked) and one endpoint violates it; issues in projects whose fields don't satisfy the query; stale UI showing an allowed pair after the query changed.
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
- Link spec not allowed to link to the target issue
- Opposite side of link spec not allowed to link to the source
- Link spec is not multiple and the source issue is already li
- Opposite side of link spec is not multiple and the target is
- Link spec is not multiple and source issue is already linked
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/1597ed8f5ca600c0.
Report an issue: GitHub.