mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
🛡️ fix: Add Null Checks to Parameter Settings to Prevent Undefined Access (#9108)
Fixes "Cannot read properties of undefined (reading 'key')" error in parameter panels by filtering out null/undefined values before mapping operations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
b9bc3123d6
commit
beff848a3f
2 changed files with 9 additions and 7 deletions
|
|
@ -79,9 +79,9 @@ export default function ModelPanel({
|
||||||
agentParamSettings[combinedKey] ?? agentParamSettings[overriddenEndpointKey] ?? [];
|
agentParamSettings[combinedKey] ?? agentParamSettings[overriddenEndpointKey] ?? [];
|
||||||
const overriddenParams = endpointsConfig[provider]?.customParams?.paramDefinitions ?? [];
|
const overriddenParams = endpointsConfig[provider]?.customParams?.paramDefinitions ?? [];
|
||||||
const overriddenParamsMap = keyBy(overriddenParams, 'key');
|
const overriddenParamsMap = keyBy(overriddenParams, 'key');
|
||||||
return defaultParams.map(
|
return defaultParams
|
||||||
(param) => (overriddenParamsMap[param.key] as SettingDefinition) ?? param,
|
.filter((param) => param != null)
|
||||||
);
|
.map((param) => (overriddenParamsMap[param.key] as SettingDefinition) ?? param);
|
||||||
}, [endpointType, endpointsConfig, model, provider]);
|
}, [endpointType, endpointsConfig, model, provider]);
|
||||||
|
|
||||||
const setOption = (optionKey: keyof t.AgentModelParameters) => (value: t.AgentParameterValue) => {
|
const setOption = (optionKey: keyof t.AgentModelParameters) => (value: t.AgentParameterValue) => {
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@ export default function Parameters() {
|
||||||
const defaultParams = paramSettings[combinedKey] ?? paramSettings[overriddenEndpointKey] ?? [];
|
const defaultParams = paramSettings[combinedKey] ?? paramSettings[overriddenEndpointKey] ?? [];
|
||||||
const overriddenParams = endpointsConfig[provider]?.customParams?.paramDefinitions ?? [];
|
const overriddenParams = endpointsConfig[provider]?.customParams?.paramDefinitions ?? [];
|
||||||
const overriddenParamsMap = keyBy(overriddenParams, 'key');
|
const overriddenParamsMap = keyBy(overriddenParams, 'key');
|
||||||
return defaultParams.map(
|
return defaultParams
|
||||||
(param) => (overriddenParamsMap[param.key] as SettingDefinition) ?? param,
|
.filter((param) => param != null)
|
||||||
);
|
.map((param) => (overriddenParamsMap[param.key] as SettingDefinition) ?? param);
|
||||||
}, [endpointType, endpointsConfig, model, provider]);
|
}, [endpointType, endpointsConfig, model, provider]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -63,7 +63,9 @@ export default function Parameters() {
|
||||||
// return setting.key;
|
// return setting.key;
|
||||||
// }),
|
// }),
|
||||||
// );
|
// );
|
||||||
const paramKeys = new Set(parameters.map((setting) => setting.key));
|
const paramKeys = new Set(
|
||||||
|
parameters.filter((setting) => setting != null).map((setting) => setting.key),
|
||||||
|
);
|
||||||
setConversation((prev) => {
|
setConversation((prev) => {
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
return prev;
|
return prev;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue