theonedev/onedev · error · ExplicitException

Undefined field: ${fieldName}

Error message

Undefined field: ${fieldName}

What it means

getFieldValues resolves each FieldInstance against the issue setting's field specs. If a stored field instance's name has no matching FieldSpec (field was deleted or renamed), an ExplicitException 'Undefined field: <name>' is thrown because the value cannot be converted.

Source

Thrown at server-core/src/main/java/io/onedev/server/model/support/issue/field/FieldUtils.java:153

			HierarchicalContext.pop();
		}
	}

	public static Map<String, Object> getFieldValues(Project project, List<FieldInstance> fieldInstances) {
		Map<String, Object> fieldValues = new HashMap<>();
		Serializable fieldBean;
		try {
			fieldBean = getFieldBeanClass(false).getDeclaredConstructor().newInstance();
		} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
				| java.lang.reflect.InvocationTargetException | NoSuchMethodException | SecurityException e) {
			throw new RuntimeException(e);
		}
		BeanDescriptor beanDescriptor = new BeanDescriptor(fieldBean.getClass());
		GlobalIssueSetting issueSetting = OneDev.getInstance(SettingService.class).getIssueSetting();
		for (FieldInstance fieldInstance : fieldInstances) {
			FieldSpec fieldSpec = issueSetting.getFieldSpec(fieldInstance.getName());
			if (fieldSpec == null)
				throw new ExplicitException("Undefined field: " + fieldInstance.getName());
			// EditContext for scripting values that read sibling fields via getInputValue(...)
			HierarchicalContext.push(newHierarchicalContext(project, beanDescriptor, fieldBean));
			try {
				Object fieldValue = fieldSpec.convertToObject(fieldInstance.getValueProvider().getValue());
				fieldValues.put(fieldInstance.getName(), fieldValue);
				String propertyName = getPropertyName(beanDescriptor, fieldInstance.getName());
				if (propertyName != null)
					beanDescriptor.getProperty(propertyName).setPropertyValue(fieldBean, fieldValue);
			} finally {
				HierarchicalContext.pop();
			}
		}
		return fieldValues;
	}
	
	private static void validateFieldValue(FieldSpec fieldSpec, String fieldName, List<String> fieldValue) {
		try {
			fieldSpec.convertToObject(fieldValue);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Re-add or restore the missing field spec in Administration > Issue Settings
  2. Remove or migrate the stale field values on the affected issues
  3. Use getFieldValues overload with fieldEdits only after verifying field names via issueSetting.getFieldSpec()

Example fix

// before
Map<String,Object> values = FieldUtils.getFieldValues(issue);
// after
if (OneDev.getInstance(SettingService.class).getIssueSetting().getFieldSpec("MyField") != null) {
    Map<String,Object> values = FieldUtils.getFieldValues(issue);
}
Defensive patterns

Strategy: try-catch

Validate before calling

for (FieldInstance f : fieldInstances)
    if (issueSetting.getFieldSpec(f.getName()) == null)
        return Result.fail("Undefined field: " + f.getName());

Try / catch

try {
    values = FieldUtils.getFieldValues(subject, project, issue);
} catch (ExplicitException e) {
    logger.warn("Skipping issue with undefined field: {}", e.getMessage());
    values = Collections.emptyMap();
}

Prevention

When it happens

Trigger: Reading field values of an issue whose custom field was removed from issue settings, or renamed, leaving stale FieldInstance records; scripts importing issues with unknown field names.

Common situations: Admin deletes a custom field while old issues still reference it; restoring issues from backup/export into a project without those field definitions.

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/2f5cb16f2ca14313. Report an issue: GitHub.