fix: Hidden parameters cause build failure (OD-2560)

This commit is contained in:
Robin Shen 2025-09-25 20:53:34 +08:00
parent a77172ef43
commit 0defe8b62a
2 changed files with 17 additions and 13 deletions

View File

@ -64,18 +64,14 @@ public class VariableInterpolator {
for (Entry<String, Input> entry : paramCombination.getParamInputs().entrySet()) {
if (paramName.equals(entry.getKey())) {
if (paramCombination.isParamVisible(paramName)) {
String paramType = entry.getValue().getType();
List<String> paramValues = new ArrayList<>();
for (String value : entry.getValue().getValues()) {
if (paramType.equals(ParamSpec.SECRET))
value = build.getJobAuthorizationContext().getSecretValue(value);
paramValues.add(value);
}
return StringUtils.join(paramValues, ",");
} else {
throw new ExplicitException("Invisible param: " + paramName);
String paramType = entry.getValue().getType();
List<String> paramValues = new ArrayList<>();
for (String value : entry.getValue().getValues()) {
if (paramType.equals(ParamSpec.SECRET))
value = build.getJobAuthorizationContext().getSecretValue(value);
paramValues.add(value);
}
return StringUtils.join(paramValues, ",");
}
}
throw new ExplicitException("Undefined param: " + paramName);

View File

@ -86,6 +86,7 @@ import io.onedev.server.util.BeanUtils;
import io.onedev.server.util.DependsOnUtils;
import io.onedev.server.util.EditContext;
import io.onedev.server.util.ReflectionUtils;
import io.onedev.server.web.editable.EditableUtils;
/**
* The main Bean Validation class. This is the core processing class of Hibernate Validator.
@ -1345,12 +1346,19 @@ public class ValidatorImpl implements Validator, ExecutableValidator {
public Object getInputValue(String name) {
var getter = BeanUtils.findGetter(bean.getClass(), name);
if (getter == null) {
throw new ExplicitException("Getter not found for property: " + name);
for (var eachGetter: BeanUtils.findGetters(bean.getClass())) {
if (EditableUtils.getDisplayName(eachGetter).equals(name)) {
getter = eachGetter;
break;
}
}
if (getter == null)
throw new ExplicitException("Getter not found for property: " + name);
}
try {
return getter.invoke(bean);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new ExplicitException("Error invoking getter for property: " + dependsOn.property(), e);
throw new ExplicitException("Error invoking getter for property: " + name, e);
}
}
});