Browse Source

fix: pre-populate schema defaults into node parameters

When a model schema loads, enum dropdowns showed "Default" but never
wrote the actual default value into node.data.parameters. This caused
the Kie API to receive missing parameter values, resulting in errors
like "mode is not within the range of allowed options."

Now a useEffect watches for schema changes and writes any schema-defined
defaults into parameters when the corresponding key is undefined.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 3 months ago
parent
commit
ce085da061
  1. 16
      src/components/nodes/ModelParameters.tsx

16
src/components/nodes/ModelParameters.tsx

@ -154,6 +154,22 @@ function ModelParametersInner({
fetchSchema();
}, [modelId, provider, replicateApiKey, falApiKey, kieApiKey, wavespeedApiKey, onInputsLoaded]);
// Pre-populate schema defaults into parameters
useEffect(() => {
if (schema.length === 0) return;
const defaults: Record<string, unknown> = {};
let hasNewDefaults = false;
for (const param of schema) {
if (param.default !== undefined && parameters[param.name] === undefined) {
defaults[param.name] = param.default;
hasNewDefaults = true;
}
}
if (hasNewDefaults) {
onParametersChange({ ...parameters, ...defaults });
}
}, [schema, parameters, onParametersChange]);
// Notify parent to resize node when schema loads
useEffect(() => {
if (schema.length > 0 && onExpandChange) {

Loading…
Cancel
Save