Changed from hardcoded config schema to a flexible one for YAML-Imports#82
Changed from hardcoded config schema to a flexible one for YAML-Imports#82Zirkonium88 wants to merge 3 commits into
Conversation
46c227e to
a33b747
Compare
|
This is an intentional tradeoff. The risk of typos slipping through is minimal because:
The panel could additionally show a non-blocking warning ("unknown values: subagents, skills — verify these are valid for your LibreChat version") but that's a UX enhancement for a follow-up, not a blocker. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a33b74751c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const nonEnumIssues = result.error.issues.filter( | ||
| (i) => i.code !== ENUM_ERROR_CODE, | ||
| ); | ||
| if (nonEnumIssues.length === 0) return { success: true }; |
There was a problem hiding this comment.
Reject non-string native enum values before bypassing
For z.nativeEnum-backed string enums such as endpoints.agents.capabilities, Zod v3 reports numeric inputs (for example capabilities: [123]) as invalid_enum_value rather than as a type error, because native enums accept string/number before membership checking. This nonEnumIssues.length === 0 branch—and the same isOnlyEnumErrors check below for YAML imports—therefore accepts and persists numeric enum entries as “forward-compatible” values, even though future capabilities are still strings. Please verify the offending value type or path before suppressing the enum issue.
Useful? React with 👍 / 👎.
| success: true, | ||
| error: undefined, | ||
| validationErrors: undefined, | ||
| appConfig: rawConfig as Record<string, t.ConfigValue>, |
There was a problem hiding this comment.
Preserve schema parsing when accepting enum-only imports
When an import contains an unknown enum value plus a misspelled or unsupported config key, configSchema.safeParse fails only on the enum because normal Zod object parsing strips unknown keys instead of reporting them; this branch then returns the original rawConfig rather than a schema-parsed object. That means the otherwise-stripped keys, and any skipped defaults/transforms, are passed on to the import flow only in the enum-forward-compatibility path. Please keep the parsed/sanitized shape when suppressing enum errors instead of returning the raw YAML object.
Useful? React with 👍 / 👎.
|
To use Codex here, create a Codex account and connect to github. |
Summary
Fixes #72 and #73.
The admin panel validates imported YAML configs and individual field edits using
configSchemafromlibrechat-data-provider. This schema usesz.nativeEnum()for fields likeendpoints.agents.capabilities, which rejects values not present in the bundled enum at build time. When LibreChat adds new enum values upstream (e.g.subagents,skills, or any future addition to OCR strategies, file sources, etc.), the admin panel rejects otherwise valid configs — blocking users from using new features even with correct YAML from the changelog.This PR makes validation lenient for enum mismatches generically across all config fields: if the only validation errors are
invalid_enum_value, the config is accepted as-is. Structural and type errors still block import. This keeps the admin panel forward-compatible with newer LibreChat versions without requiring a synchronized release.Change Type
Testing
librechat.yamlwith agent capabilities including values unknown to the current enum:Config validation failederror listingInvalid enum valueforsubagentsandskillsAlso verified:
invalid_union, notinvalid_enum_value)Test Configuration:
librechat-data-provider: 0.8.505+Checklist
Note
Medium Risk
Changes central config import and per-field validation paths; incorrect bypass logic could accept bad configs, but scope is limited to string-only enum mismatches and is covered by new tests.
Overview
Makes admin config validation tolerate unknown string enum values from newer LibreChat releases, so YAML imports and field edits are not blocked when
librechat-data-provider’s bundledz.nativeEnum()lags upstream (e.g. new agent capabilities).validateFieldValuenow ignoresinvalid_enum_valueissues whenreceivedis a string; structural/type problems and non-string enum failures (e.g. numbers in enum arrays) still fail.parseImportedYamluses the same rule for full-document validation: if enum string mismatches are the only errors, it runsparseWithEnumBypass—strip those paths,safeParsefor defaults/transforms/stripping, then restore the original enum values—so imports succeed with values preserved. Mixed validation errors still returnConfig validation failedwith paths/messages.Reviewed by Cursor Bugbot for commit 1bba590. Bugbot is set up for automated code reviews on this repo. Configure here.