theonedev/onedev · error · ExplicitException

Duplicate issue field mapping (issue: %s, field: %s)

Error message

Duplicate issue field mapping (issue: %s, field: %s)

What it means

During Gitea issue import, each imported issue's field mappings (name::value pairs) are collected into a set; if the same field name+value appears twice for one issue the import is aborted with this ExplicitException to avoid ambiguous duplicate custom-field assignments.

Source

Thrown at server-plugin/server-plugin-import-gitea/src/main/java/io/onedev/server/plugin/imports/gitea/ImportServer.java:440

									comment.setUser(userService.load(userId));
								} else {
									comment.setUser(OneDev.getInstance(UserService.class).getUnknown());
									nonExistentLogins.add(userNode.get("username").asText());
								}
								issue.getComments().add(comment);
							}
						}
						
						issue.setCommentCount(issue.getComments().size());

						Set<String> fieldAndValues = new HashSet<>();
						for (IssueField field: issue.getFields()) {
							String fieldAndValue = field.getName() + "::" + field.getValue();
							if (!fieldAndValues.add(fieldAndValue)) {
								String errorMessage = String.format(
										"Duplicate issue field mapping (issue: %s, field: %s)", 
										issueFQN, fieldAndValue);
								throw new ExplicitException(errorMessage);
							}
						}
						
						if (!extraIssueInfo.isEmpty()) {
							StringBuilder builder = new StringBuilder("|");
							for (String key: extraIssueInfo.keySet()) 
								builder.append(key).append("|");
							builder.append("\n|");
							extraIssueInfo.keySet().stream().forEach(it->builder.append("---|"));
							builder.append("\n|");
							for (String value: extraIssueInfo.values())
								builder.append(value).append("|");
							
							if (issue.getDescription() != null)
								issue.setDescription(builder.toString() + "\n\n" + issue.getDescription());
							else
								issue.setDescription(builder.toString());
						}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Review Issue Label Mappings in the import option and remove/merge entries that map different labels to the same field::value
  2. Check the specific issue (named in the message) for duplicate labels that resolve to the same mapping
  3. Deduplicate fields before import if custom preprocessing is used
  4. Re-run the import after fixing the mappings

Example fix

// before: two mappings
bug    -> Type::Bug
issue  -> Type::Bug  // duplicate for issues with both labels
// after: single mapping or distinct values
bug    -> Type::Bug
issue  -> Type::Task
Defensive patterns

Strategy: validation

Validate before calling

Set<String> seen = new HashSet<>();
for (var m : importOption.getIssueLabelMappings()) {
    if (!seen.add(m.getOneDevIssueField()))
        throw new IllegalArgumentException("Duplicate mapping: " + m.getOneDevIssueField());
}

Try / catch

try { importServer.importIssues(...); } catch (ExplicitException e) { if (e.getMessage().startsWith("Duplicate issue field mapping")) { /* fix mappings and retry */ } else throw e; }

Prevention

When it happens

Trigger: Calling importIssues (consume callback) when a Gitea issue maps two labels to the same OneDev field/value combination, or a mapping plus issue data produces the identical field name and value twice.

Common situations: Configuring two different Gitea labels to map to the same OneDev issue field value; an issue having two labels that collapse to the same field mapping; repeated import option entries.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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